From cb3e991b2b9083943a9a14655642cd7393fb4394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Fri, 15 Jul 2022 15:31:39 +0200 Subject: [PATCH] Add version change check in the version bump workflow (#3104) * Check if any changes to commit * Comment out checkout since there is a git switch * Change base branch to DEVOPS-872_version_bump_not_fail * Remove checkout version branch since git switch does that * Revert "Change base branch to DEVOPS-872_version_bump_not_fail" This reverts commit 8874702469baf17598be812a0a4c44ce0cd8eeca. --- .github/workflows/version-bump.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 8f87225415..1fc0fde1bb 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -39,12 +39,6 @@ jobs: echo "::set-output name=client::$CLIENT" git switch -c ${CLIENT}_version_bump_${VERSION} - git push -u origin ${CLIENT}_version_bump_${VERSION} - - - name: Checkout Version Branch - uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 - with: - ref: ${{ steps.branch.outputs.client }}_version_bump_${{ github.event.inputs.version_number }} ######################## # VERSION BUMP SECTION # @@ -108,22 +102,38 @@ jobs: ######################## + - name: Setup git + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + - name: Check if version changed + id: version-changed + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "::set-output name=changes_to_commit::TRUE" + else + echo "::set-output name=changes_to_commit::FALSE" + echo "No changes to commit!"; + fi + - name: Commit files + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} env: CLIENT: ${{ steps.branch.outputs.client }} VERSION: ${{ github.event.inputs.version_number }} run: | - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" git commit -m "Bumped ${CLIENT} version to ${VERSION}" -a - name: Push changes + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} env: CLIENT: ${{ steps.branch.outputs.client }} VERSION: ${{ github.event.inputs.version_number }} run: git push -u origin ${CLIENT}_version_bump_${VERSION} - name: Create Bump Version PR + if: ${{ steps.version-changed.outputs.changes_to_commit == 'TRUE' }} env: PR_BRANCH: "${{ steps.branch.outputs.client }}_version_bump_${{ github.event.inputs.version_number }}" GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"