Skip to content

Commit

Permalink
ci: use docker actions.
Browse files Browse the repository at this point in the history
This allows us to use the GHA cache when building images, which should
speed up CI considerably, even without JOBS being set to the number of
processors on the machine, since the longest build step, epics-base,
changes the least often.

This also stops publishing a latest image, which, given that we don't
support that in our ioc Dockerfile, isn't really used anywhere.
  • Loading branch information
ericonr committed Dec 11, 2023
1 parent 017d79d commit 0984f70
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions .github/workflows/base-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ jobs:
IMAGE: ${{ matrix.image.name }}
SOURCE: https://github.com/${{ github.repository }}
steps:
- uses: actions/checkout@v3
- name: Build image
run: cd ${{ matrix.image.dir }} && JOBS=$(nproc) docker compose build
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to registry
if: github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push tagged image
if: github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true' && github.ref_type == 'tag'
run: docker push $REGISTRY/$IMAGE:$TAG
- name: Push latest image
if: github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true' && github.ref_type == 'branch'
run: |
docker tag $REGISTRY/$IMAGE:$TAG $REGISTRY/$IMAGE:latest
docker push $REGISTRY/$IMAGE:latest
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push tagged image
uses: docker/bake-action@v4
with:
workdir: ${{ matrix.image.dir }}
files: docker-compose.yml
set: |
*.cache-from=type=gha,scope=${{ matrix.image.name }}
*.cache-to=type=gha,mode=max,scope=${{ matrix.image.name }}
push: ${{ github.event_name == 'push' && vars.PUSH_TO_REGISTRY == 'true' && github.ref_type == 'tag' }}

0 comments on commit 0984f70

Please sign in to comment.