From 67f8282e7dc1cb756a981e008119a54000b1abd9 Mon Sep 17 00:00:00 2001 From: dfeldick Date: Tue, 11 Jun 2024 10:10:36 -0700 Subject: [PATCH] APIGOV-28116 - dont commit if go.mod not changed --- .github/workflows/update-gomod-for-tests.yml | 21 +++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-gomod-for-tests.yml b/.github/workflows/update-gomod-for-tests.yml index 5223ac1..5b3fcc9 100644 --- a/.github/workflows/update-gomod-for-tests.yml +++ b/.github/workflows/update-gomod-for-tests.yml @@ -25,11 +25,25 @@ jobs: working-directory: . run: | make dep-version sdk=main - git config --global user.email builder-lphxmjtnt11@axway.com - git config --global user.name builder-lphxmjtnt11 - git commit --allow-empty -m "Updating SDK in go.mod" + set +e # Grep succeeds with nonzero exit codes to show results. + git status | grep modified + if [ $? -eq 0 ] + then + set -e + echo -e "Committing dependency changes" + git config --global user.email builder-lphxmjtnt11@axway.com + git config --global user.name builder-lphxmjtnt11 + git commit --allow-empty -m "Updating SDK in go.mod" + git push origin ${BRANCH_REF} + echo "gomodChanged=y" >> $GITHUB_OUTPUT + else + set -e + echo -e "No dependency changes since last run" + echo "gomodChanged=n" >> $GITHUB_OUTPUT + fi - name: Create Pull Request + if: ${{ steps.updatesdk.outputs.gomodChanged == 'y' }} id: cpr uses: peter-evans/create-pull-request@v6 with: @@ -40,6 +54,7 @@ jobs: reviewers: dfeldick - name: Enable Pull Request Automerge + if: ${{ steps.updatesdk.outputs.gomodChanged == 'y' }} run: gh pr merge APIGOV-UpdateSDKForTesting --admin --merge --subject "Merge branch APIGOV-UpdateSDKForTesting" env: GH_TOKEN: ${{ secrets.ACTION_ACCESS_TOKEN }}