fea: build docker image and publish it #7
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
| # See https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/ | |
| name: Fly Deploy | |
| concurrency: | |
| group: production # optional: ensure only one action runs at a time | |
| cancel-in-progress: true | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build-docker: | |
| name: Build Docker image locally | |
| runs-on: ubuntu-latest | |
| environment: production | |
| steps: | |
| - name: login to GitHub Container Registry | |
| run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Set docker image name to the environment | |
| run: echo "IMAGE_NAME=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV | |
| - name: Build Docker image | |
| run: docker build -t ${{ env.IMAGE_NAME }} . | |
| - name: Push Docker image | |
| run: docker push ${{ env.IMAGE_NAME }} | |
| deploy: | |
| name: Deploy fly.io app | |
| runs-on: ubuntu-latest | |
| environment: production | |
| needs: build-docker | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: superfly/flyctl-actions/setup-flyctl@master | |
| - run: flyctl deploy --ha=false --remote-only -i ${{ env.IMAGE_NAME }} | |
| env: | |
| FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
| TURSO_AUTH_TOKEN: ${{ secrets.TURSO_AUTH_TOKEN }} | |
| TURSO_CONNECTION_URL: ${{ secrets.TURSO_CONNECTION_URL }} |