{"id":15108,"date":"2019-09-24T09:00:07","date_gmt":"2019-09-24T00:00:07","guid":{"rendered":"https:\/\/www.agent-grow.com\/self20percent\/?p=15108"},"modified":"2019-09-24T08:11:44","modified_gmt":"2019-09-23T23:11:44","slug":"github-actions-rsync","status":"publish","type":"post","link":"https:\/\/www.agent-grow.com\/self20percent\/2019\/09\/24\/github-actions-rsync\/","title":{"rendered":"GitHub Actions \u3067\u5feb\u9069\u306a\u30c7\u30d7\u30ed\u30a4\u3092\u5b9f\u73fe\u3059\u308b(rsync\u30fblaravel)"},"content":{"rendered":"<h1>GitHub \u3067 CI\/CD !<\/h1>\n<p>\u7686\u3055\u3093\u3001CI\/CD \u56de\u3057\u3066\u307e\u3059\u304b\uff1f<\/p>\n<p>\u30c6\u30b9\u30c8\u3084\u3089\u30c7\u30d7\u30ed\u30a4\u3084\u3089\u306f\u81ea\u52d5\u3067\u56de\u3059\u3088\u3046\u306a\u98a8\u6f6e\u304c\u3067\u304d\u3066\u304b\u3089\u65e9\u6570\u5e74\u3002<br \/>\n\u3053\u308c\u307e\u3067\u69d8\u3005\u306a CI\/CD \u30b5\u30fc\u30d3\u30b9\u304c\u751f\u307e\u308c\u3066\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u4e00\u65b9\u3001\u4e16\u754c\u3067\u6700\u3082\u5927\u304d\u306a\u958b\u767a\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u3042\u308b GitHub \u306f\u3001<br \/>\n\u3053\u308c\u307e\u3067\u30ea\u30dd\u30b8\u30c8\u30ea\u7ba1\u7406\u4ee5\u5916\u306e\u4ed5\u7d44\u307f\u306b\u3064\u3044\u3066\u306f\u3001\u30a4\u30f3\u30c6\u30b0\u30ec\uff0d\u30b7\u30e7\u30f3\u3067\u5bfe\u5fdc\u3059\u308b\u3068\u3044\u3046\u59ff\u52e2\u3092\u3068\u3063\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n<p>\u304c\u3001\u305d\u306e GitHub \u304c\u3042\u308b\u6642\u671f\uff08\u8cb7\u53ce\u306e\u9803\uff1f\uff09\u3092\u5883\u306b\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u7ba1\u7406\uff08board \u6a5f\u80fd\uff09\u7b49\u8272\u3005\u306a\u6a5f\u80fd\u3092<br \/>\n\u6a19\u6e96\u3067\u63d0\u4f9b\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u3064\u3064\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u3093\u306a\u6d41\u308c\u3067 CI\/CD \u6a5f\u80fd\u304c\u63d0\u4f9b\u3055\u308c\u308b\u3053\u3068\u306b\u306a\u3063\u305f\u306e\u304c 2018 \u5e74\u306e\u672b\u3002<br \/>\n\u73fe\u5728\u306f\u30d1\u30d6\u30ea\u30c3\u30af\u30d9\u30fc\u30bf\u3068\u306a\u3063\u3066\u3001\u7686\u3055\u3093\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f\u3053\u306e GitHub \u306e CI\/CD \u6a5f\u80fd\u3001GitHub Actions \u3092\u4f7f\u3063\u3066<br \/>\n\u7c21\u5358\u306b\u30c7\u30d7\u30ed\u30a4\u4f5c\u696d\u3092\u3059\u308b\u65b9\u6cd5\u3092\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n<p>\u203b\u3061\u306a\u307f\u306b\u3001 2019\/8 \u9803\u306b\u3001GitHub Actions \u306f\u5927\u5e45\u306a\u6539\u5909\u304c\u52a0\u3048\u3089\u308c\u307e\u3057\u305f\u3002<br \/>\n\u3053\u306e\u5185\u5bb9\u306f 2019\/9 \u6642\u70b9\u3067\u52d5\u4f5c\u3059\u308b\u5185\u5bb9\u3067\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u8a2d\u5b9a\u3057\u3066\u307f\u3088\u3046\uff01<\/h1>\n<p>GitHub Actions \u3092\u6709\u52b9\u306b\u3059\u308b\u306b\u306f\u3068\u3066\u3082\u7c21\u5358\u3067\u3001<br \/>\n\u30eb\u30fc\u30c8\u306b\u7f6e\u3044\u305f <code>.github\/workflows<\/code> \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4e2d\u306b yaml \u30d5\u30a1\u30a4\u30eb\u3092\u914d\u7f6e\u3059\u308b\u3060\u3051\u3067\u3059\u3002<br \/>\n\u3053\u306e\u3068\u304d\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u62e1\u5f35\u5b50\u304c <code>.yml<\/code> (\u307e\u305f\u306f <code>.yaml<\/code> ) \u3067\u3042\u308c\u3070\u4f55\u3067\u3082 OK\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001laravel (PHP) \u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u60f3\u5b9a\u3067\u5b9f\u65bd\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u524d\u63d0\u6761\u4ef6\u3068\u3057\u3066\u306f\u3001<\/p>\n<ul>\n<li>\u914d\u7f6e\u5148\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30c9\u30e1\u30a4\u30f3: example.com<\/li>\n<li>\u914d\u7f6e\u5148\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u306e\u3001\u914d\u7f6e\u306b\u4f7f\u3046\u30e6\u30fc\u30b6\u30fc\u540d: john<\/li>\n<li>\u914d\u7f6e\u5148\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5185\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea: \/var\/www\/app<\/li>\n<li>\u914d\u7f6e\u5148\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3078\u306e\u30ed\u30b0\u30a4\u30f3\u65b9\u6cd5: SSH \u516c\u958b\u9375\u8a8d\u8a3c<\/li>\n<\/ul>\n<h2>\u9375\u306e\u767b\u9332<\/h2>\n<p>\u307e\u305a\u306f\u3001GitHub \u304b\u3089 SSH \u3067\u30ed\u30b0\u30a4\u30f3\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u3001<br \/>\nSSH \u306e\u9375\u3092 GitHub \u5074\u306b\u767b\u9332\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u3068\u306f\u8a00\u3063\u3066\u3082\u3068\u3066\u3082\u7c21\u5358\u3067\u3001<br \/>\n\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u30bb\u30c3\u30c6\u30a3\u30f3\u30b0\u753b\u9762\u304b\u3089\u8a2d\u5b9a\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"15112\" data-permalink=\"https:\/\/www.agent-grow.com\/self20percent\/2019\/09\/24\/github-actions-rsync\/%e7%84%a1%e9%a1%8c-85\/\" data-orig-file=\"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e.png\" data-orig-size=\"800,458\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"\u7121\u984c\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e-300x172.png\" data-large-file=\"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e.png\" src=\"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e-300x172.png\" alt=\"\" width=\"300\" height=\"172\" class=\"alignnone size-medium wp-image-15112\" srcset=\"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e-300x172.png 300w, https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e-768x440.png 768w, https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/0d40a5e4a645fc6b96e767d64ac0878e.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u666e\u901a\u306b Settings \u3092\u958b\u3044\u3066\u3001\u5de6\u306e\u30ea\u30b9\u30c8\u304b\u3089 Secrets \u3092\u9078\u3079\u3070\u3053\u306e\u30da\u30fc\u30b8\u304c\u958b\u304d\u307e\u3059\u3002<\/p>\n<p><code>https:\/\/github.com\/(\u30e6\u30fc\u30b6\u30fc\u30fb\u30b0\u30eb\u30fc\u30d7\u540d)\/(\u30ea\u30dd\u30b8\u30c8\u30ea\u540d)\/settings\/secrets<\/code><\/p>\n<p>\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u3067\u3082\u3001\u3053\u306e\u30da\u30fc\u30b8\u306f\u958b\u3051\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u306e Name \u306e\u6240\u306b\u9069\u5f53\u306a\u540d\u524d\uff08\u4eca\u56de\u306f <code>SSH_PRIVATE_KEY<\/code> \uff09\u3092\u3001<br \/>\n\u4e0b\u306e Value \u306b\u9375\u306e\u5185\u5bb9\u3092\u305d\u306e\u307e\u307e\u8cbc\u308a\u4ed8\u3051\u3066 Add secret \u30dc\u30bf\u30f3\u3092\u62bc\u3059\u3060\u3051\u3067<br \/>\nCI \u304b\u3089\u3053\u306e\u5024\u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>GitHub Actions \u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/h2>\n<p>\u3067\u306f\u5f15\u304d\u7d9a\u304d\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\n\u6700\u521d\u306b\u3001\u5b8c\u6210\u5f62\u306f\u3053\u3061\u3089\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nname: only master branch\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  deploy:\n\n    runs-on: ubuntu-latest\n\n    steps:\n      - uses: actions\/checkout@v1\n      - name: composer install\n        run: cd api \uff06\uff06 composer install\n      - name: add permission\n        run: chmod -R g+w api \uff06\uff06 sudo groupadd -f apache \uff06\uff06 sudo chown -R :apache api\n      - name: ssh key generate\n        run: echo \u201d$SSH_PRIVATE_KEY\u201d \uff1e key \uff06\uff06 chmod 600 key\n        env:\n          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}\n      - name: rsync deploy\n        run: rsync -rptgDvz --delete --exclude-from=api\/.rsyncignore -e \u201dssh -i key -o UserKnownHostsFile=\/dev\/null -o StrictHostKeyChecking=no\u201d api\/ john@example.com:\/var\/www\/app\n      - name: migrate database\n        run: ssh -i key -o UserKnownHostsFile=\/dev\/null -o StrictHostKeyChecking=no john@example.com \u2019cd \/var\/www\/app \uff06\uff06 php artisan migrate\u2019\n<\/pre>\n<p>\u4e0a\u304b\u3089\u898b\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nname: only master branch\n<\/pre>\n<p>\u3053\u3053\u306f\u305d\u306e\u307e\u307e\u3001\u5f8c\u304b\u3089\u308f\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u540d\u524d\u3092\u3064\u3051\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\non:\n  push:\n    branches:\n      - master\n<\/pre>\n<p>\u3053\u3053\u306f\u3001CI \u3092\u8d77\u52d5\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u306e\u6761\u4ef6\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001push \u3055\u308c\u305f\u3068\u304d\u3001\u3059\u306a\u308f\u3061\u30b3\u30df\u30c3\u30c8\u304c\u52d5\u3044\u305f\u3068\u304d\u306b\u5b9f\u65bd\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\non:\n  push:\n<\/pre>\n<p>\u3053\u308c\u3060\u3051\u3067\u306f\u5168\u3066\u306e\u30d6\u30e9\u30f3\u30c1\u304c\u30d7\u30c3\u30b7\u30e5\u3055\u308c\u305f\u3068\u304d\u306b\u30c7\u30d7\u30ed\u30a4\u304c\u8d70\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u306e\u3067\u3001<br \/>\nmaster \u30d6\u30e9\u30f3\u30c1\u304c\u52d5\u3044\u305f\u3068\u304d\u3060\u3051\u306b\u7d5e\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\njobs:\n  deploy:\n\n    runs-on: ubuntu-latest\n<\/pre>\n<p>\u3053\u3053\u304b\u3089\u304c\u5b9f\u969b\u306e\u52d5\u4f5c\u306b\u3064\u3044\u3066\u8a18\u8ff0\u3059\u308b\u3068\u3053\u308d\u3067\u3059\u306d\u3002<\/p>\n<p>\u5b9f\u969b\u306e\u52d5\u4f5c\u306f <code>jobs:<\/code> \u306e\u5f8c\u308d\u306b\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><code>deploy:<\/code> \u306f\u3001\u3053\u308c\u3082\u8b58\u5225\u540d\u3067\u3059\u306d\u3002\u81ea\u5206\u304c\u5206\u304b\u308c\u3070\u3069\u3093\u306a\u540d\u524d\u3067\u3082 OK\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nruns-on: ubuntu-latest\n<\/pre>\n<p>\u3053\u3053\u306e\u90e8\u5206\u306f\u3001 CI \u3092\u3069\u3093\u306a\u74b0\u5883\u3067\u5b9f\u65bd\u3059\u308b\u304b\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>ubuntu \u3060\u3051\u3067\u306a\u304f\u3001windows \u3084 mac \u3082\u4f7f\u3048\u308b\u3088\u3046\u3067\u3059\u3002<br \/>\n\u30af\u30ed\u30b9\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u30c6\u30b9\u30c8\u3057\u305f\u3044\u3068\u304d\u306b\u306f\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<p>\u6b21\u306e <code>steps:<\/code> \u304b\u3089\u3001\u30b3\u30de\u30f3\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n- uses: actions\/checkout@v1\n<\/pre>\n<p>\u3053\u308c\u306f\u3001\u81ea\u5206\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u3092\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u3059\u308b\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u306d\u3002<br \/>\n<code>uses<\/code> \u3068\u306a\u3063\u3066\u3044\u308b\u3082\u306e\u306f\u3001\u4ed6\u306e\u4eba\u304c\u4e88\u3081\u4f5c\u3063\u3066\u304f\u308c\u3066\u3044\u308b GitHub Actions \u306e\u8a2d\u5b9a\u3092\u4f7f\u3046\u305f\u3081\u306e\u3082\u306e\u3067\u3059\u3002<br \/>\n\u57fa\u672c\u7684\u306b\u30c1\u30a7\u30c3\u30af\u30a2\u30a6\u30c8\u306f\u307f\u3093\u306a\u4f7f\u3046\u306e\u3067\u3001\u3053\u306e\u3088\u3046\u306a\u5f62\u3067\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3059\u306d\u3002<\/p>\n<p>\u4ed6\u306b\u3082\u8272\u3005\u516c\u958b\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u8208\u5473\u306e\u3042\u308b\u4eba\u306f\u662f\u975e\u3002<\/p>\n<p>https:\/\/github.com\/actions<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n      - name: composer install\n        run: cd api \uff06\uff06 composer install\n<\/pre>\n<p>\u6b21\u306f composer \u3092\u4f7f\u3063\u3066\u3001\u4f9d\u5b58\u95a2\u4fc2\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b\u914d\u7f6e\u3057\u3066\u304b\u3089\u5b9f\u65bd\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001<br \/>\n\u4eca\u56de\u306f\u5168\u90e8\u30d5\u30a1\u30a4\u30eb\u7fa4\u3092\u7528\u610f\u3057\u3066\u304b\u3089\u3001\u4f9d\u5b58\u3082\u542b\u3081\u3066\u5168\u3066\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3068\u540c\u671f\u3055\u305b\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306e\u5dee\u7570\u3082\u51fa\u306b\u304f\u304f\u306a\u308b\u3068\u3044\u3046\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u304b\u3089\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n      - name: add permission\n        run: chmod -R g+w api \uff06\uff06 sudo groupadd -f apache \uff06\uff06 sudo chown -R :apache api\n<\/pre>\n<p>\u6b21\u306b\u3001\u4eca\u56de\u306f apache \u30b0\u30eb\u30fc\u30d7\u3067\u7ba1\u7406\u304c\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3001<br \/>\n\u30b0\u30eb\u30fc\u30d7\u306b\u66f8\u304d\u8fbc\u307f\u6a29\u9650\u3092\u4ed8\u4e0e\u3001apache \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\u3057\u3001\u5168\u30d5\u30a1\u30a4\u30eb\u3092 apache \u30b0\u30eb\u30fc\u30d7\u306e\u914d\u4e0b\u3068\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>rsync \u3067\u306f\u540c\u671f\u5143\u3068\u540c\u671f\u5148\u3067\u30e6\u30fc\u30b6\u30fc\u540d\u3084\u30b0\u30eb\u30fc\u30d7\u540d\u304c\u540c\u3058\u306b\u306a\u308b\u3088\u3046\u306b\u3057\u3066\u304f\u308c\u308b\u6a5f\u80fd\u304c\u3042\u308b\u306e\u3067<br \/>\n\uff08\u3082\u3061\u308d\u3093\u3001\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\u306f\u540c\u671f\u5148\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u305f\u30e6\u30fc\u30b6\u30fc\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u30fb\u30b0\u30eb\u30fc\u30d7\u540d\u306b\u306a\u308a\u307e\u3059\uff09<br \/>\n\u3053\u306e\u6a5f\u80fd\u3092\u4f7f\u3046\u524d\u63d0\u3067\u3001 apache \u30b0\u30eb\u30fc\u30d7\u306e\u7ba1\u7406\u4e0b\u306b\u7f6e\u3044\u3066\u3044\u308b\u306e\u3067\u3059\u306d\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n      - name: ssh key generate\n        run: echo \u201d$SSH_PRIVATE_KEY\u201d \uff1e key \uff06\uff06 chmod 600 key\n        env:\n          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}\n<\/pre>\n<p>SSH \u3059\u308b\u305f\u3081\u306e\u9375\u3092\u914d\u7f6e\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u5148\u307b\u3069 secrets \u306b\u767b\u9332\u3057\u305f\u5185\u5bb9\u306f <code>SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}<\/code> \u306e\u3088\u3046\u306b\u3001<br \/>\n<code>(\u74b0\u5883\u5909\u6570\u540d): ${{ secrets.(\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306b\u767b\u9332\u3057\u305f Name) }}<\/code> \u306e\u5f62\u306b\u3059\u308b\u3053\u3068\u3067<br \/>\n\u30b3\u30de\u30f3\u30c9\u5185\u3067\u74b0\u5883\u5909\u6570\u3068\u3057\u3066\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><code>echo \"$SSH_PRIVATE_KEY\" &gt; key &amp;&amp; chmod 600 key<\/code><br \/>\n\u3053\u308c\u3067\u3001\u74b0\u5883\u5909\u6570\u306b\u683c\u7d0d\u3055\u308c\u305f\u9375\u306e\u60c5\u5831\u3092 <code>key<\/code> \u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u51fa\u3057\u305f\u5f8c\u3001<br \/>\n<code>key<\/code> \u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u3092 600 \u306b\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\uff08\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\u304c\u305d\u306e\u307e\u307e\u3060\u3068 SSH \u3059\u308b\u3068\u304d\u306b\u5931\u6557\u3059\u308b\u305f\u3081\uff09<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n      - name: rsync deploy\n        run: rsync -rptgDvz --delete --exclude-from=api\/.rsyncignore -e \u201dssh -i key -o UserKnownHostsFile=\/dev\/null -o StrictHostKeyChecking=no\u201d api\/ john@example.com:\/var\/www\/app\n<\/pre>\n<p>\u3044\u3088\u3044\u3088\u5b9f\u969b\u306b\u30c7\u30d7\u30ed\u30a4\u3067\u3059\u306d\u3002<br \/>\n\u3068\u306f\u8a00\u3063\u3066\u3082\u3001\u666e\u901a\u306b rsync \u30b3\u30de\u30f3\u30c9\u3092\u305f\u305f\u3044\u3066\u3044\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001\u5927\u5207\u306a\u30d5\u30a1\u30a4\u30eb\u307e\u3067\u524a\u9664\u3055\u308c\u305f\u308a\u3057\u306a\u3044\u3088\u3046\u306b\u3001\u5fc5\u305a dry-run \u3057\u3066\u3001\u52d5\u4f5c\u3092\u78ba\u304b\u3081\u3066\u304b\u3089\u5b9f\u65bd\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\ndry-run \u306f <code>-n<\/code> \u307e\u305f\u306f <code>--dry-run<\/code> \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u5b9f\u65bd\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4eca\u66f4\u3067\u3059\u304c\u3001\u81ea\u5df1\u8cac\u4efb\u3067\u304a\u9858\u3044\u3044\u305f\u3057\u307e\u3059\u306d\u3002<\/p>\n<p>\u8a73\u3057\u3044\u3053\u3068\u306f SSH \u3084 rsync \u306e\u89e3\u8aac\u3092\u5225\u9014\u53c2\u7167\u3057\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3067\u3059\u304c\u3001<br \/>\nknown_host \u306e\u8a2d\u5b9a\u306f\u7121\u8996\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u7684\u306b\u304d\u3061\u3093\u3068\u3084\u308a\u305f\u3044\u5834\u5408\u306f\u3001\u5225\u9014\u30d5\u30a3\u30f3\u30ac\u30fc\u30d7\u30ea\u30f3\u30c8\u3092 secret \u306b\u914d\u5099\u3057\u3066\u3001<br \/>\n\u3046\u307e\u3044\u3053\u3068\u8a2d\u5b9a\u3057\u3066\u305f\u3044\u3060\u3051\u308c\u3070\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n      - name: migrate database\n        run: ssh -i key -o UserKnownHostsFile=\/dev\/null -o StrictHostKeyChecking=no john@example.com \u2019cd \/var\/www\/app \uff06\uff06 php artisan migrate\u2019\n<\/pre>\n<p>\u6700\u5f8c\u306b\u3001laravel \u306e\u6a5f\u80fd\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br \/>\n\u30c7\u30d7\u30ed\u30a4\u6642\u306b\u4e00\u7dd2\u306b\u30de\u30a4\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u3092\u8d70\u3089\u305b\u308b\u3053\u3068\u3067\u3001\u672c\u5f53\u306b\u5358\u7d14\u306b\u30b3\u30fc\u30c9\u3092 push \u3059\u308b\u3060\u3051\u3067<br \/>\n\u5168\u3066\u306e\u8a2d\u5b9a\u304c\u52dd\u624b\u306b\u5b9f\u65bd\u3055\u308c\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\n\u3068\u3066\u3082\u4fbf\u5229\u3067\u3059\u306d\u3002<\/p>\n<p>\u4ee5\u4e0a\u3067\u3001\u30c7\u30d7\u30ed\u30a4\u5b8c\u4e86\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h1>GitHub Actions \u306e CI\/CD \u3092\u6d3b\u7528\u3057\u3088\u3046\uff01<\/h1>\n<p>\u4eca\u56de\u306f\u30c7\u30d7\u30ed\u30a4\u306e\u8a2d\u5b9a\u65b9\u6cd5\u3092\u3054\u7d39\u4ecb\u3044\u305f\u3057\u307e\u3057\u305f\u3002<br \/>\n\u3082\u3061\u308d\u3093\u3001\u30c6\u30b9\u30c8\u3092\u56de\u3057\u305f\u308a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3057\u3001<br \/>\n\u30c6\u30b9\u30c8\u306e\u7d50\u679c\u3001\u30a8\u30e9\u30fc\u7d42\u4e86\u3057\u305f\u308a\u3059\u308b\u3068\u3001\u304d\u3061\u3093\u3068 GitHub \u306e\u65b9\u306b\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30d7\u30e9\u30a4\u30d9\u30fc\u30c8\u3067\u3082\u7121\u6599\u67a0\u304c\u3042\u3063\u305f\u308a\u3001\u30d1\u30d6\u30ea\u30c3\u30af\u3060\u3068\u7121\u5236\u9650\u3060\u3063\u305f\u308a\u3068\u3068\u3066\u3082\u4f7f\u3044\u52dd\u624b\u3082\u826f\u3044\u306e\u3067\u3001<br \/>\n\u662f\u975e\u4f7f\u3063\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GitHub \u3067 CI\/CD ! \u7686\u3055\u3093\u3001CI\/CD \u56de\u3057\u3066\u307e\u3059\u304b\uff1f \u30c6\u30b9\u30c8\u3084\u3089\u30c7\u30d7\u30ed\u30a4\u3084\u3089\u306f\u81ea\u52d5\u3067\u56de\u3059\u3088\u3046\u306a\u98a8\u6f6e\u304c\u3067\u304d\u3066\u304b\u3089\u65e9\u6570\u5e74\u3002 \u3053\u308c\u307e\u3067\u69d8\u3005\u306a CI\/CD \u30b5\u30fc\u30d3\u30b9\u304c\u751f\u307e\u308c\u3066\u304d\u307e\u3057\u305f\u3002 \u4e00\u65b9\u3001\u4e16\u754c\u3067\u6700\u3082\u5927\u304d\u306a\u958b\u767a [&hellip;]<\/p>\n","protected":false},"author":15,"featured_media":15113,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[515,25],"class_list":["post-15108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","tag-ci-cd","tag-github"],"jetpack_featured_media_url":"https:\/\/www.agent-grow.com\/self20percent\/wp-content\/uploads\/2019\/09\/850c7612116999490846136e772ab7fd-2.png","jetpack_shortlink":"https:\/\/wp.me\/p7Bq4F-3VG","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/15108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/comments?post=15108"}],"version-history":[{"count":0,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/posts\/15108\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media\/15113"}],"wp:attachment":[{"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/media?parent=15108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/categories?post=15108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.agent-grow.com\/self20percent\/wp-json\/wp\/v2\/tags?post=15108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}