PR dashboard #140
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 dashboard | |
| on: | |
| schedule: | |
| # hourly | |
| - cron: "0 * * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| update-dashboard: | |
| permissions: | |
| issues: write | |
| environment: protected | |
| runs-on: ubuntu-latest | |
| env: | |
| DASHBOARD_TITLE: "Pull Request Dashboard" | |
| DASHBOARD_OUTPUT: pull-request-dashboard.md | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| id: otelbot-token | |
| with: | |
| app-id: ${{ vars.OTELBOT_APP_ID }} | |
| private-key: ${{ secrets.OTELBOT_PRIVATE_KEY }} | |
| - name: Install Copilot CLI | |
| run: npm install -g @github/copilot@1.0.40 | |
| - name: Generate dashboard | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # needed for reading approver team membership (org:read) | |
| OTELBOT_TOKEN: ${{ steps.otelbot-token.outputs.token }} | |
| COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} | |
| run: | | |
| python3 .github/scripts/pull-request-dashboard.py \ | |
| --output "$DASHBOARD_OUTPUT" | |
| - name: Update or create dashboard issue | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Find the open issue with an exact title match. The search API | |
| # does not support exact phrases, so filter the results in jq. | |
| number=$(gh issue list \ | |
| --search "in:title $DASHBOARD_TITLE" \ | |
| --state open \ | |
| --limit 20 \ | |
| --json number,title \ | |
| --jq ".[] | select(.title == \"$DASHBOARD_TITLE\") | .number" \ | |
| | head -1) | |
| if [[ -n "$number" ]]; then | |
| echo "Updating existing issue #$number" | |
| gh issue edit "$number" --body-file "$DASHBOARD_OUTPUT" | |
| else | |
| echo "Creating new dashboard issue" | |
| gh issue create \ | |
| --title "$DASHBOARD_TITLE" \ | |
| --body-file "$DASHBOARD_OUTPUT" | |
| fi |