Skip to content

Commit

Permalink
ci: fix automated docker versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
tachyonicClock committed Aug 4, 2024
1 parent d145644 commit 0cc493e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 59 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/all_targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,3 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

docker:
name: "Trigger Docker Build"
if: github.ref == 'refs/heads/main' && needs.release.outputs.released == 'true'
needs: [release]
uses: ./.github/workflows/docker.yml
secrets: "inherit"
with:
tag: ${{ needs.release.outputs.tag }}
is_latest: true
61 changes: 12 additions & 49 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,25 @@
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
# Trigger the workflow on push that contains a new version tag
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
branches:
- main
jobs:
buildx:
name: Build & Publish
name: Docker Build and Push
environment: release
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}

-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Load docker/.env file. The weird syntax is because we need to append the
# CAPYMOA_VERSION to the GITHUB_ENV and we need to strip quotes from the
# value
-
name: Load .env
run: |
source docker/.env &&
echo CAPYMOA_VERSION=$CAPYMOA_VERSION >> $GITHUB_ENV
- 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 @@ -73,6 +34,8 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
file: docker/dockerfile
tags: ${{ steps.image_names.outputs.image_names }}
build-args: CAPYMOA_VERSION=${{ env.CAPYMOA_VERSION }}
tags: >-
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:${{ github.ref_name }}",
${{ secrets.DOCKERHUB_USERNAME }}/jupyter-capymoa:latest
build-args: CAPYMOA_VERSION=${{ github.ref_name }}"

0 comments on commit 0cc493e

Please sign in to comment.