Skip to content

Commit

Permalink
chore(release): don't run jobs unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
evegufy committed Apr 4, 2024
1 parent 7a6f321 commit 6179d15
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 }}

0 comments on commit 6179d15

Please sign in to comment.