mirror of
https://github.com/Felitendo/spotifast.git
synced 2026-11-01 17:33:26 +01:00
81 lines
2.8 KiB
YAML
81 lines
2.8 KiB
YAML
name: Triage open backlog
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
description: Preview without writing comments, labels, or closures
|
|
type: boolean
|
|
default: false
|
|
limit:
|
|
description: Maximum number of open reports to assess (1-100)
|
|
required: false
|
|
default: '100'
|
|
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
discussions: write
|
|
|
|
concurrency:
|
|
group: triage-open-backlog
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
discover:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.reports.outputs.matrix }}
|
|
has_reports: ${{ steps.reports.outputs.has_reports }}
|
|
steps:
|
|
- id: reports
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
TRIAGE_LIMIT: ${{ inputs.limit }}
|
|
shell: bash
|
|
run: |
|
|
if [[ ! "$TRIAGE_LIMIT" =~ ^([1-9]|[1-9][0-9]|100)$ ]]; then
|
|
echo 'limit must be between 1 and 100' >&2
|
|
exit 1
|
|
fi
|
|
|
|
query='query($owner:String!,$name:String!){repository(owner:$owner,name:$name){issues(first:100,states:OPEN,orderBy:{field:CREATED_AT,direction:ASC}){nodes{number}} discussions(first:100,orderBy:{field:CREATED_AT,direction:ASC}){nodes{number closed}}}}'
|
|
gh api graphql -f query="$query" -F owner="$GITHUB_REPOSITORY_OWNER" -F name="${GITHUB_REPOSITORY#*/}" > reports.json
|
|
matrix=$(jq -c --argjson limit "$TRIAGE_LIMIT" '{include: (([.data.repository.issues.nodes[] | {kind: "issue", number}] + [.data.repository.discussions.nodes[] | select(.closed | not) | {kind: "discussion", number}])[:$limit])}' reports.json)
|
|
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"
|
|
if [[ $(jq '.include | length' <<<"$matrix") -gt 0 ]]; then
|
|
echo 'has_reports=true' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo 'has_reports=false' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
assess:
|
|
needs: discover
|
|
if: needs.discover.outputs.has_reports == 'true'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
strategy:
|
|
fail-fast: true
|
|
max-parallel: 1
|
|
matrix: ${{ fromJSON(needs.discover.outputs.matrix) }}
|
|
steps:
|
|
- id: first_attempt
|
|
continue-on-error: true
|
|
uses: crmne/copilot-triage@v0
|
|
with:
|
|
copilot-token: ${{ secrets.COPILOT_GITHUB_TOKEN }}
|
|
github-token: ${{ github.token }}
|
|
kind: ${{ matrix.kind }}
|
|
number: ${{ matrix.number }}
|
|
dry-run: ${{ inputs.dry_run }}
|
|
debounce-seconds: 0
|
|
- if: steps.first_attempt.outcome == 'failure'
|
|
uses: crmne/copilot-triage@v0
|
|
with:
|
|
copilot-token: ${{ secrets.COPILOT_GITHUB_TOKEN }}
|
|
github-token: ${{ github.token }}
|
|
kind: ${{ matrix.kind }}
|
|
number: ${{ matrix.number }}
|
|
dry-run: ${{ inputs.dry_run }}
|
|
debounce-seconds: 0
|