PR dashboard #134
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_LABEL: "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: | | |
| set -euo pipefail | |
| number=$(gh api \ | |
| --paginate \ | |
| "repos/$GITHUB_REPOSITORY/issues?state=open&labels=$DASHBOARD_LABEL&per_page=100" \ | |
| --jq '.[] | select(.pull_request == null and .title == env.DASHBOARD_TITLE) | .number' \ | |
| | sort -n \ | |
| | sed -n '1p') | |
| 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" \ | |
| --label "$DASHBOARD_LABEL" \ | |
| --body-file "$DASHBOARD_OUTPUT" | |
| fi |