Skip to content

Commit

Permalink
ci: fix docker versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyonicClock committed Aug 3, 2024
1 parent 09b3a60 commit bbfc8b5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/all_targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
contents: write
outputs:
released: ${{ steps.release.outputs.released }}
tag: ${{ steps.release.outputs.tag }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -124,3 +125,6 @@ jobs:
needs: [release]
uses: ./.github/workflows/docker.yml
secrets: "inherit"
with:
tag: ${{ needs.release.outputs.tag }}
is_latest: true
47 changes: 36 additions & 11 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
name: Docker
on:
workflow_dispatch:
inputs:
tag:
description: "The tag of the repository to build"
required: true
default: "refs/heads/main"
is_latest:
type: boolean
description: "Whether to tag the image as latest"
required: false
default: false
workflow_call:
inputs:
tag:
type: string
description: "The tag of the repository to build"
required: true
is_latest:
type: boolean
description: "Whether to tag the image as latest"
required: false
default: false
jobs:
buildx:
name: Build & Publish
environment: release
runs-on: ubuntu-latest
env:
DOCKER_TAG: ${{ github.sha }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -26,12 +46,19 @@ jobs:
source docker/.env &&
echo CAPYMOA_VERSION=$CAPYMOA_VERSION >> $GITHUB_ENV
- name: Tagged latest?
# If we are on the master head we can tag it as latest. Otherwise we will
# use the commit sha
run: echo "DOCKER_TAG=latest" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main'

- name: Name Image
id: image_names
run: |
image_names="${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:${{ env.CAPYMOA_VERSION }}"
# If we were asked to tag as latest, add the latest tag
if [ "${{ github.event.inputs.is_latest }}" = "true" ]; then
image_names="$image_names,${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:latest"
fi
echo "$image_names"
echo "image_names=$image_names" >> $GITHUB_OUTPUT
shell: sh

-
name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -46,8 +73,6 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
file: docker/dockerfile
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:${{ env.DOCKER_TAG }},
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:${{ env.CAPYMOA_VERSION }}
tags: ${{ steps.image_names.outputs.image_names }}
build-args: CAPYMOA_VERSION=${{ env.CAPYMOA_VERSION }}

0 comments on commit bbfc8b5

Please sign in to comment.