From 4a66b91f6fe587816445360bc5b96d8cb31444eb Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Sat, 2 Sep 2023 15:28:55 +0100 Subject: [PATCH] ci/release: enable push (#4128) * ci/release: enable push Signed-off-by: Radostin Stoyanov * 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 --------- Signed-off-by: Radostin Stoyanov --- .github/workflows/ci-release.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 3f2bd07aa23..cc1809fb0aa 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -6,6 +6,7 @@ on: - main paths: - 'Version.txt' + - '.github/workflows/ci-release.yml' # Cancel any preceding run on the pull request. concurrency: @@ -19,6 +20,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Get version run: | @@ -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 }} @@ -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