Skip to content

Commit 49af7c7

Browse files
committed
build: ensure workflow succeeds when there are no new error codes
1 parent f05fa02 commit 49af7c7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/update_error_databases.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,21 @@ jobs:
8787
node lib/node_modules/@stdlib/error/tools/pkg2id/scripts/build.js
8888
node lib/node_modules/@stdlib/error/tools/id2pkg/scripts/build.js
8989
90+
# Check if there are any changes to the error databases:
91+
- name: 'Check for changes'
92+
id: check_changes
93+
run: |
94+
if [ -z "$(git diff lib/node_modules/@stdlib/error/tools/database/data/data.csv | grep '^+')" ]; then
95+
echo "No changes detected in error databases. Skipping PR creation."
96+
echo "has_changes=false" >> $GITHUB_OUTPUT
97+
else
98+
echo "Changes detected in error databases."
99+
echo "has_changes=true" >> $GITHUB_OUTPUT
100+
fi
101+
90102
# Generate comment with Markdown table of added error codes:
91103
- name: 'Generate comment body with Markdown table of added error codes'
104+
if: steps.check_changes.outputs.has_changes == 'true'
92105
run: |
93106
# Save the added lines from the diff to a temporary file:
94107
git diff lib/node_modules/@stdlib/error/tools/database/data/data.csv | grep '^+' | sed 's/^+//' > /tmp/diff.csv
@@ -123,11 +136,13 @@ jobs:
123136

124137
# Disable Git hooks:
125138
- name: 'Disable Git hooks'
139+
if: steps.check_changes.outputs.has_changes == 'true'
126140
run: |
127141
rm -rf .git/hooks
128142
129143
# Import GPG key to sign commits:
130144
- name: 'Import GPG key to sign commits'
145+
if: steps.check_changes.outputs.has_changes == 'true'
131146
# Pin action to full length commit SHA
132147
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
133148
with:
@@ -138,6 +153,7 @@ jobs:
138153

139154
# Create a pull request with the updated declarations:
140155
- name: 'Create pull request'
156+
if: steps.check_changes.outputs.has_changes == 'true'
141157
id: cpr
142158
# Pin action to full length commit SHA
143159
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5

0 commit comments

Comments
 (0)