From 3acb9a073d9ed6396ce7235792aa2174b96419c4 Mon Sep 17 00:00:00 2001 From: William Dutton Date: Tue, 28 May 2024 10:50:20 +1000 Subject: [PATCH] Update build pipeline so it does not trigger on empty head of branch --- .github/{releases.yml => release.yml} | 6 +++--- .github/workflows/update.yml | 30 +++++++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) rename .github/{releases.yml => release.yml} (87%) diff --git a/.github/releases.yml b/.github/release.yml similarity index 87% rename from .github/releases.yml rename to .github/release.yml index dbe71ea..6b90b96 100644 --- a/.github/releases.yml +++ b/.github/release.yml @@ -5,9 +5,9 @@ changelog: categories: - title: Breaking Changes 🛠 - labels: - - Semver-Major - - breaking-change + labels: + - Semver-Major + - breaking-change - title: 🏕 Features labels: - '*' diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index d4d7843..d022cd7 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -60,7 +60,8 @@ jobs: - run: npm ci - - name: Update + - name: Update & Push git tags + if: ${{ env.HAVE_GIT_DEPLOY_KEY == 'true' }} run: | force="${{ github.event.inputs.force }}" dry="${{ github.event.inputs.dry }}" @@ -68,14 +69,31 @@ jobs: if [ "$bump" = "" ]; then bump="patch" fi - + + # Fetch the latest tags + git fetch --tags + + # Get the latest tag + LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`) + + # Get the current commit hash + CURRENT_COMMIT=$(git rev-parse HEAD) + + # Check if there are changes between the latest tag and the current commit + if git diff --quiet $LATEST_TAG $CURRENT_COMMIT; then + if [ "$force" != "1" ]; then + echo "No changes detected between the latest tag ($LATEST_TAG) and the current commit ($CURRENT_COMMIT)." >> $GITHUB_STEP_SUMMARY + exit 0 + else + echo "Force flag set continuing: No changes detected between the latest tag ($LATEST_TAG) and the current commit ($CURRENT_COMMIT)." >> $GITHUB_STEP_SUMMARY + fi + else + echo "Changes detected between the latest tag ($LATEST_TAG) and the current commit ($CURRENT_COMMIT)." >> $GITHUB_STEP_SUMMARY + fi + # Bump Version npm version "$bump" - - - name: Push git tags - if: ${{ env.HAVE_GIT_DEPLOY_KEY == 'true' }} - run: | dry="${{ github.event.inputs.dry }}" # Push if [ "$dry" = "1" ]; then