consolidate ci into a single action
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
deleted file mode 100644
index 1dabe8c..0000000
--- a/.github/workflows/build.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: Build
-on:
- workflow_run:
- workflows: [CI]
- types: [completed]
- branches: [main]
-jobs:
- build:
- runs-on: ubuntu-latest
- if: ${{ github.event.workflow_run.conclusion == 'success' }}
- permissions:
- contents: read
- packages: write
- steps:
- - uses: actions/checkout@v4
- - uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - uses: docker/metadata-action@v5
- id: meta
- with:
- images: ghcr.io/${{ github.repository }}
- tags: |
- type=raw,value=latest,enable={{is_default_branch}}
- type=sha,prefix=
- type=raw,value={{date 'YYYYMMDDHHmmss'}}
- - uses: docker/build-push-action@v5
- with:
- context: .
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b143d44..b78a074 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -19,3 +19,59 @@ jobs:
- run: make test
- run: coverage report
+ build:
+ runs-on: ubuntu-latest
+ needs: [ci]
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@v4
+ - uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - uses: docker/metadata-action@v5
+ id: meta
+ with:
+ images: ghcr.io/${{ github.repository }}
+ tags: |
+ type=raw,value=latest,enable={{is_default_branch}}
+ type=sha,prefix=
+ type=raw,value={{date 'YYYYMMDDHHmmss'}}
+ - uses: docker/build-push-action@v5
+ with:
+ context: .
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+
+ deploy:
+ runs-on: ubuntu-latest
+ needs: [build]
+ environment: production
+ concurrency:
+ group: deploy-group
+ cancel-in-progress: true
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@v4
+ - uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+ - run: |
+ docker pull ${IMAGE}:$(git rev-parse --short HEAD)
+ docker tag ${IMAGE}:$(git rev-parse --short HEAD) ${IMAGE}:fly
+ docker push ${IMAGE}:fly
+ env:
+ IMAGE: ghcr.io/${{ github.repository }}
+
+ - uses: superfly/flyctl-actions/setup-flyctl@master
+ - run: flyctl deploy --remote-only
+ env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
deleted file mode 100644
index e459ed4..0000000
--- a/.github/workflows/deploy.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
-# https://fly.io/docs/app-guides/continuous-deployment-with-github-actions/
-
-name: Deploy
-on:
- workflow_run:
- workflows: [Build]
- types: [completed]
- branches: [main]
-jobs:
- deploy:
- runs-on: ubuntu-latest
- if: ${{ github.event.workflow_run.conclusion == 'success' }}
- environment: production
- concurrency: deploy-group
- permissions:
- contents: read
- packages: write
- steps:
- - uses: actions/checkout@v4
- with:
- ref: ${{ github.event.workflow_run.head_sha }}
-
- - uses: docker/login-action@v3
- with:
- registry: ghcr.io
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - run: |
- docker pull ${IMAGE}:$(git rev-parse --short HEAD)
- docker tag ${IMAGE}:$(git rev-parse --short HEAD) ${IMAGE}:fly
- docker push ${IMAGE}:fly
- env:
- IMAGE: ghcr.io/${{ github.repository }}
-
- - uses: superfly/flyctl-actions/setup-flyctl@master
- - run: flyctl deploy --remote-only
- env:
- FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}