github/update: improve summary for generated files

This commit is contained in:
Matt Sturgeon 2024-07-15 10:08:59 +01:00
parent bd1dddaf50
commit cff06c8570
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -71,10 +71,17 @@ jobs:
nix run .#generate-files -- --commit nix run .#generate-files -- --commit
new=$(git show --no-patch --format=%h) new=$(git show --no-patch --format=%h)
if [ "$old" != "$new" ]; then if [ "$old" != "$new" ]; then
summary=$(git show --no-patch --format=%s) body=$(git show --no-patch --format=%b)
echo "summary=$summary" >> "$GITHUB_OUTPUT"
echo "body<<EOF" >> "$GITHUB_OUTPUT" echo "body<<EOF" >> "$GITHUB_OUTPUT"
git show --no-patch --format=%b >> "$GITHUB_OUTPUT" if [ -n "$body" ]; then
# Multi-file changes are listed in the body
echo "$body" >> "$GITHUB_OUTPUT"
else
# Single-file changes are only in the summary,
# e.g. "generated: Updated none-ls.nix"
git show --no-patch --format=%s | \
sed -e 's/^generated:/-/' >> "$GITHUB_OUTPUT"
fi
echo "EOF" >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT"
fi fi
@ -96,7 +103,7 @@ jobs:
``` ```
## Generate ## Generate
${{ steps.generate.outputs.body || steps.generate.outputs.summary || 'No changes' }} ${{ steps.generate.outputs.body || 'No changes' }}
- name: Print summary - name: Print summary
if: ${{ steps.pr.outputs.pull-request-number }} if: ${{ steps.pr.outputs.pull-request-number }}