eletrotupi / tcc/ commit / 5a5529d

deploy: deploy to prod

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 5a5529d8880cea7f121f2e2e8cb26d1fb487dc94
Parents: 8285983
1 file(s) changed
  • .github/workflows/deploy.yml +29 -0
.github/workflows/deploy.yml
1 1
name: Deploy
2 2

3 3
on:
4 4
  push:
5 5
    branches:
▸ 45 unchanged lines
51 51
          context: ./api
52 52
          file: ./api/Dockerfile.production
53 53
          push: true
54 54
          tags: ${{ steps.meta.outputs.tags }}
55 55
          labels: ${{ steps.meta.outputs.labels }}
56 +

57 +

58 +
  deploy-production:
59 +
    name: Deploy to production
60 +
    needs: build-and-push
61 +
    runs-on: ubuntu-latest
62 +
    if: github.ref == 'refs/heads/master'
63 +
    environment: production
64 +

65 +
    steps:
66 +
      - name: Deploy via SSH
67 +
        uses: appleboy/ssh-action@v1
68 +
        with:
69 +
          host: ${{ secrets.VPS_HOST }}
70 +
          username: ${{ secrets.VPS_USER }}
71 +
          key: ${{ secrets.VPS_SSH_KEY }}
72 +
          script: |
73 +
            set -e
74 +
            cd /srv/app/production
75 +

76 +
            docker pull ghcr.io/${{ github.repository }}:latest
77 +

78 +
            sed -i "s/^IMAGE_TAG=.*/IMAGE_TAG=latest/" .env
79 +

80 +
            docker compose up -d --no-deps --force-recreate api
81 +

82 +
            sleep 3
83 +
            # Dump the logs for a while
84 +
            docker compose logs --tail=50 api