diff --git a/.github/workflows/all_targets.yml b/.github/workflows/all_targets.yml index 09709f8..fdcd300 100644 --- a/.github/workflows/all_targets.yml +++ b/.github/workflows/all_targets.yml @@ -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 @@ -124,3 +125,6 @@ jobs: needs: [release] uses: ./.github/workflows/docker.yml secrets: "inherit" + with: + tag: ${{ needs.release.outputs.tag }} + is_latest: true diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index e4c5878..ec814d6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 @@ -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 @@ -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 }}