Skip to content

Commit

Permalink
docker tags & pushing
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Jan 9, 2024
1 parent efbeb85 commit f209cca
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- '.mailmap'
push:
branches: [master]
tags: ['v**']
paths-ignore:
- '**.md'
- 'VirtualBox/**'
Expand All @@ -26,7 +27,39 @@ jobs:
matrix:
type: [gpu, cpu]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.ref }} # fix SHA
- uses: docker/metadata-action@v5
id: meta
with:
images: |
synerbi/sirf
ghcr.io/${{ github.repository }}
flavor: |
latest=auto
suffix=${{ matrix.type == 'gpu' && 'gpu,onlatest=true' || '' }}
tags: |
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.licenses=Apache-2.0${{ matrix.type == 'gpu' && ' AND BSD-3-Clause AND GPL-3.0' || '' }}
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
with:
username: ${{ secrets.DOCKER_USR }}
password: ${{ secrets.DOCKER_PWD }}
- name: increase disk space
run: ./.github/workflows/GHA_increase_disk_space.sh
- name: cache
uses: actions/cache@v3
with:
Expand All @@ -35,9 +68,33 @@ jobs:
- id: build
name: build
run: |
suffix=${{ matrix.type == 'gpu' && '-gpu' || '' }}
# pull base image
base_image=ghcr.io/${{ github.repository }}:scipy$suffix
docker pull $base_image || :
# pull sirf image
docker pull ghcr.io/${{ github.repository }}:${{ fromJSON(steps.meta.outputs.json).tags[0] }} || :
# rebuild sirf image
./docker/compose.sh -r ${{ matrix.type == 'gpu' && '-C' || '-G' }}
echo "image=synerbi/sirf:jupyter${{ matrix.type == 'gpu' && '-gpu' || '' }}" >> $GITHUB_OUTPUT
image=synerbi/sirf:jupyter$suffix
echo "image=$image" >> "$GITHUB_OUTPUT"
# tag potentially newer base image
docker tag synerbi/sirf:scipy$suffix $base_image
echo "base_image=$base_image" >> "$GITHUB_OUTPUT"
# make a dummy Dockerfile to use with build-push-action
context=$(mktemp -d)
echo "FROM $image" >> "$context/Dockerfile"
echo "context=$context" >> "$GITHUB_OUTPUT"
- name: test CIL
run: >
docker run --rm -v ./.github/workflows:/gh --user $(id -u) --group-add users
${{ steps.build.outputs.image }} /gh/test_cil.sh
- uses: docker/build-push-action@v5
with:
context: ${{ steps.build.outputs.context }}
push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- if: github.ref == 'refs/heads/master'
name: push base image
run: docker push ${{ steps.build.outputs.base_image }}

0 comments on commit f209cca

Please sign in to comment.