Skip to content

Commit

Permalink
ci/release: enable push (#4128)
Browse files Browse the repository at this point in the history
* ci/release: enable push

Signed-off-by: Radostin Stoyanov <[email protected]>

* ci/release: skip release if tag exists

To update the container image in DockerHub we need to trigger the
release workflow but skip the creation of a new release since the
corresponding tag already exists.

Signed-off-by: Radostin Stoyanov <[email protected]>

---------

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored Sep 2, 2023
1 parent 5b66fa4 commit 4a66b91
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- 'Version.txt'
- '.github/workflows/ci-release.yml'

# Cancel any preceding run on the pull request.
concurrency:
Expand All @@ -19,6 +20,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get version
run: |
Expand All @@ -27,7 +30,20 @@ jobs:
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAG=$TAG" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
TAG="${{ env.TAG }}"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists, skipping release creation."
echo "tag_exists=true" >> $GITHUB_OUTPUT
else
echo "Tag $TAG does not exist."
echo "tag_exists=false" >> $GITHUB_OUTPUT
fi
- name: Release
if: steps.check_tag.outputs.tag_exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.TAG }}
Expand All @@ -44,9 +60,10 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image to registry
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: p4lang/p4c:${{ env.VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 4a66b91

Please sign in to comment.