0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

git actionsでgit push時お名前のVPSサーバ(ubuntu)のソースを更新する

0
Posted at

鍵を作成

お名前のデフォルトの秘密鍵は使わず、自分でパスワードなしの秘密鍵を作成しその鍵で接続できるようにします
※ここではその説明は省きます

Simple workflowを作成

該当のリポジトリーのActionsを選択し「Simple workflow」を検索する
image.png

ワークフローを作成

name: CI
on:
  push:
    branches: [main]
  pull_request:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install SSH Key for Deploy
        uses: appleboy/ssh-action@master
        with:
          key: ${{ secrets.SK }}
          host: ${{secrets.SSH_HOST}}
          username: ${{secrets.SSH_USERNAME}}
          port: ${{secrets.SSH_PORT}}
          script: |
            cd github/laravel-app
            git pull origin main     

環境変数を設定する

該当のリポジトリーの[Settings]-[Settings]-[secrets and variables]-[Action]の「Repository secrets」を設定する
image.png

項目 設定値 内容
SK 秘密鍵のキー SSH の 秘密キー
SSH_HOST 157.x.xxx.xxx VPS の IPアドレス
SSH_USERNAME user VPS で設定したユーザーネーム
SSH_PORT 22 SSH へ接続する PORT 番号(デフォルトは 22)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?