Skip to content

Commit

Permalink
chore: move to reusable docker workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Dec 3, 2024
1 parent 5d47ef4 commit d1d3c9c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 27 deletions.
24 changes: 24 additions & 0 deletions .github/actions/save-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Save Docker Images
description: Builds all docker images and saves them as artifacts
inputs:
service:
description: The service to build
required: true
runs:
using: "composite"
# Make sure to keep these cache entries in sync with those in writecache.yml
steps:
- name: Init Hermit
uses: cashapp/[email protected]
- name: Build Docker Image
shell: bash
run: |
just build-docker ${{ inputs.service }}
mkdir -p artifacts/ftl-${{ inputs.service }}
docker save -o artifacts/ftl-${{ inputs.service }}/ftl-${{ inputs.service }}.tar ftl0/ftl-${{ inputs.service }}:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
with:
name: docker-${{ inputs.service }}-artifact
path: artifacts/ftl-${{ inputs.service }}
retention-days: 1
13 changes: 13 additions & 0 deletions .github/actions/shard-docker-builds/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Shard Docker Builds
description: Outputs a matrix of all services to build
outputs:
matrix:
description: A matrix of all services to build
value: ${{ steps.set-matrix.outputs.matrix }}
runs:
using: "composite"
steps:
- uses: cashapp/[email protected]
- id: set-matrix
shell: bash
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
25 changes: 13 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,24 +224,25 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cashapp/[email protected]
- name: Checkout code
uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
docker-build:
name: Shard Docker Builds
uses: ./.github/actions/shard-docker-builds
build-docker-images:
name: Build ${{ matrix.service }} Docker Image
needs: docker-shard
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.docker-shard.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- uses: cashapp/[email protected]
- uses: ./.github/actions/build-cache
- name: Build Docker Image
run: just build-docker ${{ matrix.service }}
- name: Checkout code
uses: actions/checkout@v4
- name: Build Image and Save
uses: ./.github/actions/save-docker-image
with:
service: ${{ matrix.service }}
console-e2e:
name: Console e2e
# if: github.event_name != 'pull_request' || github.event.action == 'enqueued' || contains( github.event.pull_request.labels.*.name, 'run-all')
Expand Down Expand Up @@ -394,13 +395,13 @@ jobs:
fi
docker-success:
name: Docker Success
needs: [docker-build]
needs: [build-docker-images]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check docker builds result
run: |
if [[ "${{ needs.docker-build.result }}" == "failure" ]]; then
if [[ "${{ needs.build-docker-images.result }}" == "failure" ]]; then
echo "Docker builds failed"
exit 1
else
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ jobs:
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cashapp/[email protected]
- name: Checkout code
uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(just list-docker-images | tr -d '\n' | jq -R -s -c 'split(" ")')" >> "$GITHUB_OUTPUT"
name: Shard Docker Builds
uses: ./.github/actions/shard-docker-builds
build-docker-images:
name: Build ${{ matrix.service }} Docker Image
needs: docker-shard
Expand All @@ -24,19 +25,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Init Hermit
uses: cashapp/[email protected]
- name: Build Docker Image
run: |
just build-docker ${{ matrix.service }}
mkdir -p artifacts/ftl-${{ matrix.service }}
docker save -o artifacts/ftl-${{ matrix.service }}/ftl-${{ matrix.service }}.tar ftl0/ftl-${{ matrix.service }}:latest
- name: Temporarily save Docker image
uses: actions/upload-artifact@v4
- name: Build Image and Save
uses: ./.github/actions/save-docker-image
with:
name: docker-${{ matrix.service }}-artifact
path: artifacts/ftl-${{ matrix.service }}
retention-days: 1
service: ${{ matrix.service }}
release-docker:
name: Release Docker Images
runs-on: ubuntu-latest
Expand Down

0 comments on commit d1d3c9c

Please sign in to comment.