Add GitHub Actions workflow for building and pushing Docker images on… #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Push Docker Images on Tag | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' # Triggers only on tags like v0.1.2, v0.1.2.dev1, etc. | ||
| workflow_dispatch: | ||
| jobs: | ||
| build-and-push: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| IMAGE_BASE: isisacceleratorcontrols/poly-lithic | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Extract version from tag | ||
| id: vars | ||
| run: | | ||
| TAG_NAME=${GITHUB_REF#refs/tags/} | ||
| echo "VERSION=${TAG_NAME}" >> $GITHUB_ENV | ||
| echo "version=${TAG_NAME}" >> $GITHUB_OUTPUT | ||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Build Docker images with version injection | ||
| run: | | ||
| docker build --pull --rm --target vanilla \ | ||
| --build-arg VERSION=${VERSION} \ | ||
| -f Dockerfile -t $IMAGE_BASE:base-${VERSION} . | ||
| docker build --pull --rm --target torch \ | ||
| --build-arg VERSION=${VERSION} \ | ||
| -f Dockerfile -t $IMAGE_BASE:torch-${VERSION} . | ||
| docker build --pull --rm --target tensorflow \ | ||
| --build-arg VERSION=${VERSION} \ | ||
| -f Dockerfile -t $IMAGE_BASE:tensorflow-${VERSION} . | ||
| - name: Push versioned images | ||
| run: | | ||
| docker push $IMAGE_BASE:base-${VERSION} | ||
| docker push $IMAGE_BASE:torch-${VERSION} | ||
| docker push $IMAGE_BASE:tensorflow-${VERSION} | ||
| - name: Tag and push latest if version is pure semver | ||
| if: ${{ steps.vars.outputs.version =~ '^v[0-9]+\\.[0-9]+\\.[0-9]+$' }} | ||
|
Check failure on line 51 in .github/workflows/docker-build.yml
|
||
| run: | | ||
| echo "Tag is a pure semver release — tagging latest" | ||
| docker tag $IMAGE_BASE:base-${VERSION} $IMAGE_BASE:base-latest | ||
| docker tag $IMAGE_BASE:torch-${VERSION} $IMAGE_BASE:torch-latest | ||
| docker tag $IMAGE_BASE:tensorflow-${VERSION} $IMAGE_BASE:tensorflow-latest | ||
| docker tag $IMAGE_BASE:base-latest $IMAGE_BASE:latest | ||
| docker push $IMAGE_BASE:base-latest | ||
| docker push $IMAGE_BASE:torch-latest | ||
| docker push $IMAGE_BASE:tensorflow-latest | ||
| docker push $IMAGE_BASE:latest | ||