Improve backchannel reliability with PID-based socket naming #285
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Documentation Check | |
| on: | |
| # Use pull_request_target to run in the context of the base branch | |
| # This allows commenting on PRs from forks | |
| pull_request_target: | |
| types: [closed] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number to analyze' | |
| required: true | |
| type: number | |
| permissions: | |
| pull-requests: read | |
| contents: read | |
| issues: write | |
| jobs: | |
| check-docs-needed: | |
| # Only run on the dotnet org to avoid running on forks | |
| if: (github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch') && github.repository_owner == 'dotnet' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Install GitHub Copilot CLI | |
| run: | | |
| npm install -g @github/copilot || { | |
| echo "Error: Failed to install GitHub Copilot CLI" | |
| exit 1 | |
| } | |
| - name: Set PR number | |
| id: pr | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| echo "number=${{ inputs.pr_number }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Get PR details | |
| id: pr_details | |
| run: | | |
| if ! gh pr view ${{ steps.pr.outputs.number }} --json title,author --jq '{title: .title, author: .author.login}' > pr-info.json; then | |
| echo "Error: Failed to fetch PR #${{ steps.pr.outputs.number }}" | |
| exit 1 | |
| fi | |
| TITLE=$(jq -r '.title' pr-info.json) | |
| AUTHOR=$(jq -r '.author' pr-info.json) | |
| if [ -z "$TITLE" ] || [ "$TITLE" == "null" ]; then | |
| echo "Error: Could not extract PR title" | |
| exit 1 | |
| fi | |
| echo "title=$TITLE" >> $GITHUB_OUTPUT | |
| echo "author=$AUTHOR" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Get PR diff | |
| id: diff | |
| run: | | |
| if ! gh pr diff ${{ steps.pr.outputs.number }} > pr-diff.txt; then | |
| echo "Error: Failed to fetch diff for PR #${{ steps.pr.outputs.number }}" | |
| exit 1 | |
| fi | |
| if [ ! -s pr-diff.txt ]; then | |
| echo "Warning: PR diff is empty, no changes to analyze" | |
| echo "NO_DOCS_NEEDED" > pr-diff.txt | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Generate documentation requirements with Copilot | |
| id: analyze | |
| run: | | |
| if [ ! -f .github/prompts/docs-audit-prompt.md ]; then | |
| echo "Error: Prompt file .github/prompts/docs-audit-prompt.md not found" | |
| exit 1 | |
| fi | |
| cat .github/prompts/docs-audit-prompt.md > prompt.txt | |
| echo "" >> prompt.txt | |
| echo "PR #${{ steps.pr.outputs.number }}: ${{ steps.pr_details.outputs.title }}" >> prompt.txt | |
| echo "" >> prompt.txt | |
| echo "PR Diff:" >> prompt.txt | |
| cat pr-diff.txt >> prompt.txt | |
| if ! copilot -p "$(cat prompt.txt)" > analysis.txt 2>copilot-error.log; then | |
| echo "Error: Copilot CLI failed" | |
| echo "Error details:" | |
| cat copilot-error.log | |
| exit 1 | |
| fi | |
| if [ ! -s analysis.txt ]; then | |
| echo "Error: Copilot produced no output" | |
| exit 1 | |
| fi | |
| cat analysis.txt | |
| env: | |
| COPILOT_GITHUB_TOKEN: ${{ secrets.DOCS_COPILOT_TOKEN }} | |
| - name: Check if docs needed | |
| id: docs_check | |
| run: | | |
| if grep -q "NO_DOCS_NEEDED" analysis.txt; then | |
| echo "docs_needed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "docs_needed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Output documentation analysis results | |
| run: | | |
| if [ ! -f analysis.txt ]; then | |
| echo "Error: Analysis file not found" | |
| exit 1 | |
| fi | |
| echo "============================================" | |
| echo "Documentation Analysis for PR #${{ steps.pr.outputs.number }}" | |
| echo "PR Title: ${{ steps.pr_details.outputs.title }}" | |
| echo "PR Author: ${{ steps.pr_details.outputs.author }}" | |
| echo "============================================" | |
| echo "" | |
| if [ "${{ steps.docs_check.outputs.docs_needed }}" == "false" ]; then | |
| echo "✅ No documentation updates required" | |
| else | |
| echo "📝 Documentation updates recommended:" | |
| echo "" | |
| cat analysis.txt | |
| fi | |
| echo "" | |
| echo "============================================" | |
| - name: Create issue on aspire.dev repo | |
| if: steps.docs_check.outputs.docs_needed == 'true' | |
| id: create_issue | |
| run: | | |
| ISSUE_BODY="## Documentation Update Required | |
| This issue was automatically created based on changes from dotnet/aspire PR #${{ steps.pr.outputs.number }}. | |
| **PR Title:** ${{ steps.pr_details.outputs.title }} | |
| **PR Author:** @${{ steps.pr_details.outputs.author }} | |
| **PR Link:** https://github.com/${{ github.repository }}/pull/${{ steps.pr.outputs.number }} | |
| ## Recommended Documentation Updates | |
| $(cat analysis.txt) | |
| " | |
| ISSUE_URL=$(gh issue create \ | |
| --repo microsoft/aspire.dev \ | |
| --title "Docs update for dotnet/aspire#${{ steps.pr.outputs.number }}: ${{ steps.pr_details.outputs.title }}" \ | |
| --body "$ISSUE_BODY" \ | |
| --label "docs-from-code") | |
| echo "issue_url=$ISSUE_URL" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| - name: Comment on PR | |
| run: | | |
| if [ "${{ steps.docs_check.outputs.docs_needed }}" == "true" ]; then | |
| COMMENT="## 📝 Documentation Update Needed | |
| Hey @${{ steps.pr_details.outputs.author }}! This PR requires documentation updates. | |
| An issue has been created to track the documentation work: ${{ steps.create_issue.outputs.issue_url }} | |
| <details> | |
| <summary>Recommended Updates</summary> | |
| $(cat analysis.txt) | |
| </details>" | |
| else | |
| COMMENT="## ✅ No Documentation Updates Needed | |
| Hey @${{ steps.pr_details.outputs.author }}! This PR does not require documentation updates. | |
| For more details, check the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." | |
| fi | |
| gh pr comment ${{ steps.pr.outputs.number }} --body "$COMMENT" | |
| env: | |
| GH_TOKEN: ${{ github.token }} |