diff --git a/.github/workflows/auto_deploy.yml b/.github/workflows/auto_deploy.yml new file mode 100644 index 0000000..097091b --- /dev/null +++ b/.github/workflows/auto_deploy.yml @@ -0,0 +1,30 @@ +name: Auto Deploy +run-name: ChatGP is deploying +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Tailscale + uses: tailscale/github-action@v2 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + tags: tag:ci + - name: Deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST_HACKASON}} + username: ${{ secrets.SSH_USERNAME_HACKASON}} + key: ${{ secrets.SSH_PRIVATE_KEY_HACKASON}} + port: ${{ secrets.SSH_PORT_HACKASON}} + script: | + cd ~/ChatGP + git pull origin main + git checkout main + bash script/down.sh + bash script/up.sh diff --git a/README.md b/README.md index 9875808..7f51024 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,26 @@ docker compose -f docker-compose.prod.yml run --rm view yarn build docker compose -f docker-compose.prod.yml up -d ``` +### Deletion + +```bash +docker compose -f docker-compose.prod.yml down +``` + +### Use Script + +Installtionをまとめて実行 + +```bash +$ bash ./script/up.sh +``` + +Deletionを実行 + +```bash +$ bash ./script/down.sh +``` + ## File Structure - `api/` @@ -34,6 +54,9 @@ docker compose -f docker-compose.prod.yml up -d - Next.js を用いてフロントエンドを構築 +- `script/` + + - インストールや削除を行うシェルスクリプト - `docker-compose.yml` - 複数のコンテナを定義し、実行するための設定 diff --git a/script/down.sh b/script/down.sh new file mode 100644 index 0000000..929a6bb --- /dev/null +++ b/script/down.sh @@ -0,0 +1 @@ +docker-compose -f docker-compose.prod.yml down diff --git a/script/up.sh b/script/up.sh new file mode 100644 index 0000000..ff69c6b --- /dev/null +++ b/script/up.sh @@ -0,0 +1,4 @@ +docker-compose -f docker-compose.prod.yml build +docker compose -f docker-compose.prod.yml run --rm view yarn +docker compose -f docker-compose.prod.yml run --rm view yarn build +docker compose -f docker-compose.prod.yml up -d