Skip to content

PR dashboard

PR dashboard #656

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@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
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
# Use GraphQL instead of `gh issue list --search` because the
# search index has been observed to omit issues, which would
# cause this step to create a duplicate dashboard issue instead
# of updating the existing one.
owner="${GITHUB_REPOSITORY%/*}"
name="${GITHUB_REPOSITORY#*/}"
number=$(gh api graphql --paginate \
-F owner="$owner" -F name="$name" -F label="$DASHBOARD_LABEL" \
-f query='
query ($owner: String!, $name: String!, $label: String!, $endCursor: String) {
repository(owner: $owner, name: $name) {
issues(
first: 100
after: $endCursor
states: OPEN
filterBy: { labels: [$label] }
orderBy: { field: CREATED_AT, direction: ASC }
) {
pageInfo { hasNextPage endCursor }
nodes { number title }
}
}
}' \
--jq ".data.repository.issues.nodes[] | select(.title == \"$DASHBOARD_TITLE\") | .number" \
| 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