Skip to content

Commit

Permalink
Don't run workflow if tags don't match.
Browse files Browse the repository at this point in the history
  • Loading branch information
abizjak committed Apr 11, 2024
1 parent b744954 commit 4e4d1fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/release-auction-sponsored-txs-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
run: |
export FRONTEND_VERSION=$(jq -r .version sponsoredTransactionsAuction/frontend/package.json)
export BACKEND_VERSION=$(yq .package.version sponsoredTransactionsAuction/backend/Cargo.toml)
export FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/$IMAGE_NAME:$FRONTEND_VERSION-$BACKEND_VERSION"
export VERSION=$FRONTEND_VERSION-$BACKEND_VERSION
export FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/$IMAGE_NAME:$VERSION"
echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}"
# Make sure the image does not exist. Abort if we can retrieve any metadata.
if docker manifest inspect ${FULL_IMAGE_TAG} > /dev/null; then
Expand All @@ -44,12 +45,20 @@ jobs:
else
# Store the full image tag into a tag variable for the following step.
echo "tag=${FULL_IMAGE_TAG}" > "$GITHUB_OUTPUT"
echo "version=${VERSION}" > "$GITHUB_OUTPUT"
fi
- name: Build and push Docker image
if: startsWith(${{ github.ref_name }}, format('cis2-sponsored-transactions/{0}', ${{ steps.meta.output.version }}))
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./sponsoredTransactionsAuction/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tag }}
tags: ${{ steps.meta.outputs.tag }}

- name: Fail
if: ! startsWith(${{ github.ref_name }}, format('cis2-sponsored-transactions/{0}', ${{ steps.meta.output.version }}))
run:
echo "::error Tag does not match version."
exit 1
2 changes: 1 addition & 1 deletion .github/workflows/release-sponsored-txs-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
file: ./sponsoredTransactions/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tag }}
tags: ${{ steps.meta.outputs.tag }}

0 comments on commit 4e4d1fb

Please sign in to comment.