|
| 1 | +name: Deploy Email Worker to Development |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - dev |
| 7 | + paths: |
| 8 | + - 'apps/api/**' |
| 9 | + - 'infra/docker-compose.dev.yml' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: dev-deploy |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + build-and-push: |
| 22 | + name: Build and Push Docker Image to GHCR |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v4 |
| 28 | + |
| 29 | + - name: Set up QEMU for cross-platform builds |
| 30 | + uses: docker/setup-qemu-action@v2 |
| 31 | + |
| 32 | + - name: Set up Docker Buildx |
| 33 | + uses: docker/setup-buildx-action@v2 |
| 34 | + |
| 35 | + - name: Log in to GitHub Container Registry |
| 36 | + uses: docker/login-action@v2 |
| 37 | + with: |
| 38 | + registry: ghcr.io |
| 39 | + username: ${{ github.actor }} |
| 40 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - name: Build and push multi-arch image |
| 43 | + run: | |
| 44 | + docker buildx build \ |
| 45 | + --platform linux/amd64,linux/arm64 \ |
| 46 | + --push \ |
| 47 | + -t ghcr.io/${{ github.repository_owner }}/core-email-worker:dev \ |
| 48 | + ./apps/api/cmd/email_worker |
| 49 | +
|
| 50 | + run-migrations: |
| 51 | + name: Run Goose Migrations |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: build-and-push |
| 54 | + |
| 55 | + steps: |
| 56 | + - name: Checkout repository |
| 57 | + uses: actions/checkout@v4 |
| 58 | + |
| 59 | + - name: Install Goose |
| 60 | + run: | |
| 61 | + curl -fsSL https://raw.githubusercontent.com/pressly/goose/master/install.sh | sh |
| 62 | +
|
| 63 | + - name: Run migrations |
| 64 | + run: | |
| 65 | + goose -dir ./apps/api/internal/db/migrations postgres "${{ secrets.DEV_DB_URL }}" up |
| 66 | +
|
| 67 | + deploy: |
| 68 | + name: Deploy to Development Server |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: [build-and-push, run-migrations] |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: SSH proxy commmand |
| 74 | + uses: appleboy/ssh-action@v1 |
| 75 | + with: |
| 76 | + host: ${{ secrets.SSH_HOST_SWAMPHACKS }} |
| 77 | + username: ${{ secrets.SSH_USERNAME_SWAMPHACKS }} |
| 78 | + key: ${{ secrets.SSH_KEY_SWAMPHACKS }} |
| 79 | + port: ${{ secrets.SSH_PORT_SWAMPHACKS }} |
| 80 | + proxy_host: ${{ secrets.SSH_HOST_JUMP }} |
| 81 | + proxy_username: ${{ secrets.SSH_USERNAME_JUMP }} |
| 82 | + proxy_key: ${{ secrets.SSH_KEY_JUMP }} |
| 83 | + proxy_port: ${{ secrets.SSH_PORT_JUMP }} |
| 84 | + script: | |
| 85 | + cd /home/admin/core/infra |
| 86 | + git fetch |
| 87 | + git checkout dev |
| 88 | + git reset --hard origin/dev |
| 89 | + git pull |
| 90 | + infisical export --env=dev --format=dotenv --path="/api" --projectId=${{ secrets.INFISICAL_PROJECT_ID }} > ./secrets/.env.dev.api |
| 91 | + docker compose -f docker-compose.dev.yml pull dev-email-worker |
| 92 | + docker compose -f docker-compose.dev.yml up -d --no-deps --force-recreate dev-email-worker |
0 commit comments