Skip to content

Commit af77ff2

Browse files
committed
Enhance docs workflow to include commit SHA in commit messages and PR body for better traceability
1 parent 46a82b8 commit af77ff2

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/docs.yaml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,22 @@ jobs:
2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
30+
3031
- name: Setup Dart
3132
uses: dart-lang/setup-dart@v1
33+
3234
- name: Install dependencies
3335
run: dart pub get
36+
3437
- name: Analyze project source
3538
run: dart analyze
39+
3640
- name: Get version from pubspec.yaml
3741
id: get_version
3842
run: |
3943
VERSION=$(grep '^version:' pubspec.yaml | head -n1 | cut -d ' ' -f2)
4044
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
4146
- name: Generate docs
4247
run: dart doc
4348

@@ -96,7 +101,10 @@ jobs:
96101
# Check if there are any changes to commit (FIXED LOGIC)
97102
if ! git diff --cached --quiet; then
98103
echo "Changes detected, committing..."
99-
git commit -m "Update docs for $VERSION"
104+
# Get the commit SHA that triggered the workflow
105+
TRIGGER_COMMIT=${{ github.sha }}
106+
COMMIT_MSG="Update docs for $VERSION (generated from $TRIGGER_COMMIT)"
107+
git commit -m "$COMMIT_MSG"
100108
git push -f origin "$BRANCH"
101109
else
102110
echo "No changes to commit."
@@ -120,7 +128,12 @@ jobs:
120128
BRANCH=docs-for-$VERSION
121129
PR_TITLE="Docs for $VERSION"
122130
PR_BODY="Automated documentation update for version $VERSION."
123-
131+
132+
# If triggered by a PR, mention it in the PR body
133+
if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ github.event.pull_request.number }}" ]; then
134+
PR_BODY="$PR_BODY\n\nTriggered by #${{ github.event.pull_request.number }}"
135+
fi
136+
124137
# Check if a PR already exists
125138
PR_NUMBER=$(gh pr list --base gh-pages --head "$BRANCH" --state open --json number --jq '.[0].number' || echo "")
126139
if [ -z "$PR_NUMBER" ]; then

0 commit comments

Comments
 (0)