Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions .github/workflows/pr-review-dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
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
Expand Down Expand Up @@ -44,15 +45,33 @@ jobs:
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)
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"
Expand All @@ -61,5 +80,6 @@ jobs:
echo "Creating new dashboard issue"
gh issue create \
--title "$DASHBOARD_TITLE" \
--label "$DASHBOARD_LABEL" \
--body-file "$DASHBOARD_OUTPUT"
fi
Loading