Skip to content

Commit

Permalink
Reworked GHA workflow to allow multiple environments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellockyer committed Nov 13, 2024
1 parent 4273f98 commit 066daeb
Showing 1 changed file with 51 additions and 21 deletions.
72 changes: 51 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,62 @@ jobs:
- name: Run Biome
run: biome ci .

build-test-deploy:
name: Build, Test and Deploy
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Run Tests
run: yarn test

- name: Export ActivityPub image to .tar
run: docker save activitypub -o activitypub.tar

- name: Export Migrations image to .tar
run: docker save migrations -o migrations.tar

- name: Upload ActivityPub image to GHA
uses: actions/upload-artifact@v4
with:
name: activitypub.tar
path: activitypub.tar

- name: Upload Migrations image to GHA
uses: actions/upload-artifact@v4
with:
name: migrations.tar
path: migrations.tar

deploy:
name: Deploy
needs: [lint, test]
if: github.ref == 'refs/heads/main'
environment: build
runs-on: ubuntu-latest
steps:
- name: "Checkout"
- name: Checkout
uses: actions/checkout@v4

- name: Download ActivityPub image from GHA
uses: actions/download-artifact@v4
with:
name: activitypub.tar
path: activitypub.tar

- name: Download Migrations image from GHA
uses: actions/download-artifact@v4
with:
name: migrations.tar
path: migrations.tar

- name: Load ActivityPub image
run: docker load -i activitypub.tar

- name: Load Migrations image
run: docker load -i migrations.tar

- name: ActivityPub Docker meta
id: activitypub-docker-metadata
uses: docker/metadata-action@v5
Expand All @@ -55,23 +103,6 @@ jobs:
type=semver,pattern={{major}}
type=sha,priority=1100
- name: "Build Docker Image for ActivityPub"
uses: docker/build-push-action@v6
with:
context: .
load: true
tags: ${{ steps.activitypub-docker-metadata.outputs.tags }}

- name: "Build Docker Image for Migrations"
uses: docker/build-push-action@v6
with:
context: migrate
load: true
tags: ${{ steps.migrations-docker-metadata.outputs.tags }}

- name: "Run Tests"
run: yarn test

- name: "Login to GAR"
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
Expand All @@ -81,7 +112,6 @@ jobs:
password: ${{ secrets.SERVICE_ACCOUNT_KEY }}

- name: "Push ActivityPub Docker Image"
if: github.ref == 'refs/heads/main'
uses: docker/build-push-action@v6
with:
context: .
Expand Down

0 comments on commit 066daeb

Please sign in to comment.