Deploy using SSH and Docker Compose #93
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy using SSH and Docker Compose | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| name: Run ssh command on host machine | |
| runs-on: ubuntu-latest | |
| environment: deploy | |
| 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:wrx-sh-ci | |
| - name: Run ssh deploy command | |
| run: | | |
| ssh -o StrictHostKeyChecking=no github-actions@hetzner-server " | |
| cd ~/wrx.sh | |
| git fetch origin main | |
| git reset --hard origin/main | |
| echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| docker compose -f docker/docker-compose.prod.yml -p wrx-sh pull | |
| docker compose -f docker/docker-compose.prod.yml -p wrx-sh --env-file=./.env up --detach --no-build --remove-orphans | |
| docker compose -f docker/docker-compose.prod.yml -p wrx-sh restart caddy | |
| docker compose -f docker/docker-compose.prod.yml -p wrx-sh restart vector | |
| docker system prune --all --volumes --force | |
| " |