From 6179d1532e21408d858fa2d4829f4142e80dd827 Mon Sep 17 00:00:00 2001 From: Evelyn Gurschler Date: Thu, 4 Apr 2024 14:43:02 +0200 Subject: [PATCH] chore(release): don't run jobs unnecessarily --- .github/workflows/release.yml | 62 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 560168d4..386c47f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,9 @@ jobs: permissions: contents: write runs-on: ubuntu-latest + outputs: + app-version: ${{ steps.app-version.outputs.current }} + version-check: ${{ steps.version-check.outputs.exists }} steps: - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 @@ -60,8 +63,26 @@ jobs: CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" CR_SKIP_EXISTING: "true" + - name: Get current appVersion + id: app-version + run: | + current=$(cat ./charts/ssi-credential-issuer/Chart.yaml | grep "appVersion:" | head -1 | cut -d ":" -d " " -f2) + echo "current=$current" >> $GITHUB_OUTPUT + echo "Exported $current appVersion" + + - name: Check for previous version + id: version-check + run: | + exists=$(git tag -l "v${{ steps.app-version.outputs.current }}") + if [[ -n "$exists" ]]; then + echo "exists=true" >> $GITHUB_OUTPUT + else + echo "exists=false" >> $GITHUB_OUTPUT + fi + release-images: needs: release-helm-chart + if: needs.release-helm-chart.outputs.version-check == 'false' permissions: contents: read runs-on: ubuntu-latest @@ -89,37 +110,17 @@ jobs: with: fetch-depth: 0 - - name: Get current appVersion - id: app-version - run: | - current=$(cat ./charts/ssi-credential-issuer/Chart.yaml | grep "appVersion:" | head -1 | cut -d ":" -d " " -f2) - echo "current=$current" >> $GITHUB_OUTPUT - echo "Exported $current appVersion" - - - name: Check for previous version - id: version-check - run: | - exists=$(git tag -l "v${{ steps.app-version.outputs.current }}") - if [[ -n "$exists" ]]; then - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi - - - name: Login to GitHub Container Registry + - name: Login to DockerHub uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3.1.0 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - if: steps.version-check.outputs.exists == 'false' - name: Set up Docker Buildx uses: docker/setup-buildx-action@2b51285047da1547ffb1b2203d8be4c0af6b1f20 # v3.2.0 - if: steps.version-check.outputs.exists == 'false' - name: Set up QEMU uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 - if: steps.version-check.outputs.exists == 'false' # Create SemVer or ref tags dependent of trigger event - name: Docker meta @@ -133,13 +134,12 @@ jobs: type=ref,event=branch type=ref,event=pr type=raw,value=latest - type=semver,pattern={{version}},value=${{ steps.app-version.outputs.current }} - type=semver,pattern={{major}},value=${{ steps.app-version.outputs.current }} - type=semver,pattern={{major}}.{{minor}},value=${{ steps.app-version.outputs.current }} - if: steps.version-check.outputs.exists == 'false' + type=semver,pattern={{version}},value=${{ needs.release-helm-chart.outputs.app-version }} + type=semver,pattern={{major}},value=${{ needs.release-helm-chart.outputs.app-version }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.release-helm-chart.outputs.app-version }} - name: Build and push Docker images - uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 + uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 with: context: . file: ${{ matrix.dockerfile }} @@ -148,7 +148,6 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - if: steps.version-check.outputs.exists == 'false' # https://github.com/peter-evans/dockerhub-description - name: Update Docker Hub description @@ -158,10 +157,10 @@ jobs: password: ${{ secrets.DOCKER_HUB_TOKEN }} repository: ${{ matrix.image }} readme-filepath: ${{ matrix.dockernotice }} - if: steps.version-check.outputs.exists == 'false' create-tag: - needs: release-images + needs: [release-helm-chart, release-images] + if: needs.release-helm-chart.outputs.version-check == 'false' permissions: contents: write runs-on: ubuntu-latest @@ -173,6 +172,5 @@ jobs: - name: Create and push git tag run: | - git tag v${{ needs.release-images.outputs.app-version }} - git push origin v${{ needs.release-images.outputs.app-version }} - if: needs.release-images.outputs.version-check == 'false' + git tag v${{ needs.release-helm-chart.outputs.app-version }} + git push origin v${{ needs.release-helm-chart.outputs.app-version }}