{"id":358,"date":"2024-03-13T23:45:42","date_gmt":"2024-03-13T14:45:42","guid":{"rendered":"https:\/\/shugomatsuzawa.com\/techblog\/?p=358"},"modified":"2024-03-13T23:45:44","modified_gmt":"2024-03-13T14:45:44","slug":"github-actions%e3%81%a7vps%ef%bc%88lightsail%ef%bc%89%e3%81%ab%e3%83%87%e3%83%97%e3%83%ad%e3%82%a4%e3%81%97%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/shugomatsuzawa.com\/techblog\/2024\/03\/13\/358\/","title":{"rendered":"GitHub Actions\u3067VPS\uff08Lightsail\uff09\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066\u307f\u305f"},"content":{"rendered":"\n<p>\u30c6\u30b9\u30c8\u3084\u30c7\u30d7\u30ed\u30a4\u306e\u81ea\u52d5\u5316\u306b\u5f79\u7acb\u3064GitHub Actions\u3092\u4f7f\u3063\u3066\u307f\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u8a66\u3057\u306bVPS\u306b\u81ea\u52d5\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3068\u3044\u3046\u306e\u3092\u3084\u3063\u3066\u307f\u305f\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u300cActions\u300d\u30da\u30fc\u30b8\u306e\u300cset up a workflow yourself\u300d\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3002<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6a21ef049789e&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6a21ef049789e\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"266\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-1024x266.png\" alt=\"\" class=\"wp-image-361\" srcset=\"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-1024x266.png 1024w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-300x78.png 300w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-768x200.png 768w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-1536x399.png 1536w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/705bc7097e328135782cda769155be80-2048x532.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u62e1\u5927\u3059\u308b\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>.github\/workflows\u306bmain.yml\u3092\u4f5c\u6210\u3059\u308b\u753b\u9762\u306b\u306a\u308b\u306e\u3067\u3001\u30ef\u30fc\u30af\u30d5\u30ed\u30fc\u3092\u4f5c\u3063\u3066\u3044\u304f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name: Deploying Website\non:\n  push:\n    branches:\n      - main\njobs:\n  deploy:\n    name: Deploy\n    runs-on: ubuntu-latest\n    steps:\n    - name: executing remote ssh commands using password\n      uses: appleboy\/ssh-action@v1.0.3\n      with: # \u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5165\u529b\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\n        host: ${{ secrets.SSH_HOST }} # \u30db\u30b9\u30c8\u540d\n        username: ${{ secrets.SSH_USERNAME }} # SSH \u30e6\u30fc\u30b6\u540d\n        key: ${{ secrets.SSH_PRIVATE_KEY }} # \u79d8\u5bc6\u9375\u306e\u5185\u5bb9\n        script: |\n          cd \/opt\/bitnami\/wordpress\n          git switch main\n          git pull origin main<\/code><\/pre>\n\n\n\n<p><code>on<\/code>\u3067\u30c8\u30ea\u30ac\u30fc\u3092\u8a2d\u5b9a\u3059\u308b\u3002\u4eca\u56de\u306fmain\u30d6\u30e9\u30f3\u30c1\u306b\u30d7\u30c3\u30b7\u30e5\u3057\u305f\u6642\u306b\u5b9f\u884c\u3059\u308b\u3002<br><code>jobs<\/code>\u306b\u51e6\u7406\u306e\u5185\u5bb9\u3092\u66f8\u3044\u3066\u3044\u304f\u3002<br><code>jobs.\u30b8\u30e7\u30d6\u8b58\u5225\u5b50.runs-on<\/code>\u3067\u306f\u3001\u5b9f\u884c\u3059\u308bOS\u3092<code>ubuntu-latest<\/code>\u3001<code>windows-latest<\/code>\u3001<code>macos-latest<\/code>\u304b\u3089\u9078\u3079\u308b\u3002<br><code>jobs.\u30b8\u30e7\u30d6\u8b58\u5225\u5b50.steps<\/code>\u306b\u30bf\u30b9\u30af\u306e\u5185\u5bb9\u3092\u66f8\u304f\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f<a href=\"https:\/\/github.com\/marketplace\/actions\/ssh-remote-commands\" data-type=\"link\" data-id=\"https:\/\/github.com\/marketplace\/actions\/ssh-remote-commands\" target=\"_blank\" rel=\"noreferrer noopener\">SSH Remote Commands<\/a>\u3092\u4f7f\u7528\u3059\u308b\u306e\u3067\u3001<code>uses<\/code>\u3067\u4f7f\u7528\u3059\u308b\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3059\u308b\u3002<br><a href=\"https:\/\/github.com\/marketplace\/actions\/ssh-remote-commands#input-variables\" data-type=\"link\" data-id=\"https:\/\/github.com\/marketplace\/actions\/ssh-remote-commands#input-variables\" target=\"_blank\" rel=\"noreferrer noopener\">\u30a2\u30af\u30b7\u30e7\u30f3\u306e\u5165\u529b\u30d1\u30e9\u30e1\u30fc\u30bf<\/a>\u3067\u3042\u308b<code>host<\/code>\u3001<code>username<\/code>\u3001<code>key<\/code>\u3092\u5165\u529b\u3057\u3001\u5b9f\u884c\u3059\u308b\u30b3\u30de\u30f3\u30c9\u3092<code>script<\/code>\u306b\u5165\u529b\u3057\u3066\u3044\u304f\u3002<br>\u3057\u304b\u3057\u3001Git\u7ba1\u7406\u4e0b\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u30b5\u30fc\u30d0\u30fc\u306e\u63a5\u7d9a\u60c5\u5831\u3092\u8f09\u305b\u308b\u308f\u3051\u306b\u306f\u3044\u304b\u306a\u3044\u3060\u308d\u3046\u3002<br>\u305d\u3093\u306a\u5834\u5408\u306f\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n\n\n\n<figure data-wp-context=\"{&quot;imageId&quot;:&quot;6a21ef0497dd3&quot;}\" data-wp-interactive=\"core\/image\" data-wp-key=\"6a21ef0497dd3\" class=\"wp-block-image size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"556\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-1024x556.png\" alt=\"\" class=\"wp-image-362\" srcset=\"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-1024x556.png 1024w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-300x163.png 300w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-768x417.png 768w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-1536x834.png 1536w, https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2024\/03\/da557eb846c0d4b2ec090e975f6cf142-2048x1112.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button\n\t\t\tclass=\"lightbox-trigger\"\n\t\t\ttype=\"button\"\n\t\t\taria-haspopup=\"dialog\"\n\t\t\taria-label=\"\u62e1\u5927\u3059\u308b\"\n\t\t\tdata-wp-init=\"callbacks.initTriggerButton\"\n\t\t\tdata-wp-on--click=\"actions.showLightbox\"\n\t\t\tdata-wp-style--right=\"state.imageButtonRight\"\n\t\t\tdata-wp-style--top=\"state.imageButtonTop\"\n\t\t>\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\" \/>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure>\n\n\n\n<p>\u300cSetting\u300d\uff1e\u300cSecrets and variables\u300d\uff1e\u300cActions\u300d\u3092\u958b\u304f\u3068\u3001\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u767b\u9332\u304c\u3067\u304d\u308b\u3002<br>\u3053\u3053\u306bSSH\u306e\u8a8d\u8a3c\u30ad\u30fc\u306a\u3069\u3092\u4fdd\u5b58\u3057\u3066\u304a\u304f\u3068\u3001\u8ab0\u306b\u3082\u898b\u3089\u308c\u306a\u3044\u3002<br>\u547c\u3073\u51fa\u3059\u6642\u306f<code>${{ secrets.\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\u306e\u540d\u524d }}<\/code>\u307f\u305f\u3044\u306a\u611f\u3058\u3067\u4f7f\u3048\u308b\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u3061\u306a\u307f\u306b<\/h2>\n\n\n\n<p>SSH Remote Commands\u306f<a href=\"https:\/\/github.com\/appleboy\/ssh-action\/issues\/146\" data-type=\"link\" data-id=\"https:\/\/github.com\/appleboy\/ssh-action\/issues\/146\" target=\"_blank\" rel=\"noreferrer noopener\">\u307e\u3060IPv6\u3067\u306e\u63a5\u7d9a\u306b\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044<\/a>\u3089\u3057\u3044\u306e\u3067\u3001VPS\u306e\u56fa\u5b9aIPv4\u30a2\u30c9\u30ec\u30b9\u306f\u5fc5\u8981\u3060\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u53c2\u8003<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/softwarenote.info\/p3789\/\" data-type=\"link\" data-id=\"https:\/\/softwarenote.info\/p3789\/\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Actions \u3092\u5229\u7528\u3057\u305f\u672c\u756a\u74b0\u5883\u9069\u7528\uff08\u30c7\u30d7\u30ed\u30a4\uff09\u306e\u65b9\u6cd5 | \u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u96d1\u8a18<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.github.com\/ja\/actions\/deployment\/about-deployments\/deploying-with-github-actions\" data-type=\"link\" data-id=\"https:\/\/docs.github.com\/ja\/actions\/deployment\/about-deployments\/deploying-with-github-actions\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub Actions \u3092\u4f7f\u7528\u3057\u3066\u30c7\u30d7\u30ed\u30a4\u3059\u308b &#8211; GitHub Docs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/appleboy\/ssh-action\" data-type=\"link\" data-id=\"https:\/\/github.com\/appleboy\/ssh-action\" target=\"_blank\" rel=\"noreferrer noopener\">appleboy\/ssh-action: GitHub Actions for executing remote ssh commands.<\/a><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"\u30c6\u30b9\u30c8\u3084\u30c7\u30d7\u30ed\u30a4\u306e\u81ea\u52d5\u5316\u306b\u5f79\u7acb\u3064GitHub Actions\u3092\u4f7f\u3063\u3066\u307f\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u8a66\u3057\u306bVPS\u306b\u81ea\u52d5\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3068\u3044\u3046\u306e\u3092\u3084\u3063\u3066\u307f\u305f\u3002 \u307e\u305a\u300cActions\u300d\u30da\u30fc\u30b8\u306e\u300cset up a workflow yoursel [&hellip;]","protected":false},"author":1,"featured_media":276,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[8],"tags":[66,92,9,10],"class_list":["post-358","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system-management","tag-lightsail","tag-github","tag-linux","tag-memo"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/shugomatsuzawa.com\/techblog\/wp-content\/uploads\/sites\/3\/2023\/10\/code-7522129_1280.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/comments?post=358"}],"version-history":[{"count":4,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":365,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/posts\/358\/revisions\/365"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media\/276"}],"wp:attachment":[{"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/media?parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/categories?post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shugomatsuzawa.com\/techblog\/wp-json\/wp\/v2\/tags?post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}