55 branches : [dev] # Trigger on PRs targeting dev
66jobs :
77 update :
8+ if : github.actor != 'dependabot[bot]' && github.actor != 'dependabot-preview[bot]'
89 runs-on : ubuntu-latest
910 steps :
1011 - uses : actions/checkout@v4
1920 run : |
2021 mkdir -p wiki
2122 ISSUES=$(gh issue list --json title,createdAt --jq '.[] | "- \(.title) (Created: \(.createdAt))"' || echo "No issues found")
22- echo "# Project Updates\n\n## Recent Issues\n$ISSUES" > wiki/Home.md
23+ echo -e "# Project Updates\n\n## Recent Issues\n$ISSUES" > wiki/Home.md
2324 git clone https://${{ github.actor }}:${{ secrets.DEMO_GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git wiki-temp || (
2425 echo "Error: Wiki repo not found. Please initialize the wiki in the GitHub UI at https://github.com/${{ github.repository }}/wiki"
2526 exit 1
@@ -28,13 +29,19 @@ jobs:
2829 cd wiki-temp
2930 git config user.name "GitHub Actions"
3031 git config user.email "actions@github.com"
31- git checkout dev || git checkout -b dev
32+ git checkout master || git checkout -b master
3233 git add .
3334 git commit -m "docs: auto-update wiki" || echo "No changes to commit"
34- git push https://${{ github.actor }}:${{ secrets.DEMO_GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git dev
35+ git push https://${{ github.actor }}:${{ secrets.DEMO_GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git master
3536 - name : Auto-Update Project
3637 if : github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'dev'
3738 run : |
3839 ISSUE_NUMBER=${{ github.event.pull_request.number }}
39- ISSUE_ID=$(gh api graphql -f query="query { repository(owner: \"${{ github.repository_owner }}\", name: \"${{ github.repository_name }}\") { issue(number: $ISSUE_NUMBER) { id } } }" --jq '.data.repository.issue.id')
40- gh api graphql -f query="mutation { updateProjectV2ItemFieldValue(input: { projectId: \"${{ secrets.PROJECT_ID }}\", itemId: \"$ISSUE_ID\", fieldId: \"${{ secrets.STATUS_FIELD_ID }}\", value: { singleSelectOptionId: \"${{ secrets.DONE_OPTION_ID }}\" } }) { projectV2Item { id } } }"
40+ PR_BODY=$(gh pr view $ISSUE_NUMBER --json body --jq '.body')
41+ LINKED_ISSUE_NUM=$(echo "$PR_BODY" | grep -oE 'Closes #([0-9]+)' | sed 's/Closes #//g' | head -n1)
42+ if [ -n "$LINKED_ISSUE_NUM" ]; then
43+ ISSUE_ID=$(gh api graphql -f query="query { repository(owner: \"${{ github.repository_owner }}\", name: \"${{ github.repository_name }}\") { issue(number: $LINKED_ISSUE_NUM) { id } } }" --jq '.data.repository.issue.id')
44+ gh api graphql -f query="mutation { updateProjectV2ItemFieldValue(input: { projectId: \"${{ secrets.PROJECT_ID }}\", itemId: \"$ISSUE_ID\", fieldId: \"${{ secrets.STATUS_FIELD_ID }}\", value: { singleSelectOptionId: \"${{ secrets.DONE_OPTION_ID }}\" } }) { projectV2Item { id } } }"
45+ else
46+ echo "No linked issue found in PR body (e.g., 'Closes #X'). Skipping project update."
47+ fi
0 commit comments