Skip to content

Commit ed1f7c7

Browse files
authored
Check if NIMS and NIMG versions are different before committing (#585)
* Don't commit version changes if empty * Add conditional for pushing commit to branch * Use GITHUB_OUTPUT for check * Move brackets outside whole expression * Add a fi statement. Use a boolean variable
1 parent 27b465e commit ed1f7c7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.github/workflows/Publish_NIMS.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,20 @@ jobs:
5454
working-directory: ./ni_measurementlink_generator
5555

5656
- name: Commit file changes
57+
id: commit
5758
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
5859
run: |
59-
git config --local user.email "[email protected]"
60-
git config --local user.name "GitHub Action"
61-
git add .
62-
git commit -m "Promote NIMS package version and update Sphinx generated files in _docs" -a
60+
echo "version_changed=false" >> $GITHUB_OUTPUT
61+
if [ -n "$(git status --porcelain)" ]; then
62+
git config --local user.email "[email protected]"
63+
git config --local user.name "GitHub Action"
64+
git add .
65+
git commit -m "Promote NIMS and NIMG package version" -a
66+
echo "version_changed=true" >> $GITHUB_OUTPUT
67+
fi
6368
6469
- name: Push changes to the appropriate branch
65-
if: ${{ startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/') }}
70+
if: ${{ steps.commit.outputs.version_changed && (startsWith(github.event.release.target_commitish, 'main') || startsWith(github.event.release.target_commitish, 'releases/')) }}
6671
uses: CasperWA/push-protected@v2
6772
with:
6873
token: ${{ secrets.ADMIN_PAT }}

0 commit comments

Comments
 (0)