diff --git a/.github/workflows/gallery-agent.yaml b/.github/workflows/gallery-agent.yaml index afeafcb24..ee791038b 100644 --- a/.github/workflows/gallery-agent.yaml +++ b/.github/workflows/gallery-agent.yaml @@ -48,23 +48,57 @@ jobs: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@1958fcbe2ca8bd93af633f11e97d44e567e945af PATH="$PATH:$HOME/go/bin" make protogen-go - - name: Collect URLs from open gallery-agent PRs + - name: Process gallery-agent PR commands + env: + GH_TOKEN: ${{ secrets.UPDATE_BOT_TOKEN }} + REPO: ${{ github.repository }} + SEARCH: 'chore(model gallery) in:title :robot:' + run: | + # Walk open gallery-agent PRs and act on maintainer comments: + # /gallery-agent blacklist → label `gallery-agent/blacklisted` + close (never repropose) + # /gallery-agent recreate → close without label (next run may repropose) + # Only comments from OWNER / MEMBER / COLLABORATOR are honored so + # random users can't drive the bot. + gh label create gallery-agent/blacklisted \ + --repo "$REPO" --color ededed \ + --description "gallery-agent must not repropose this model" 2>/dev/null || true + + prs=$(gh pr list --repo "$REPO" --state open --search "$SEARCH" --json number --jq '.[].number') + for pr in $prs; do + cmds=$(gh pr view "$pr" --repo "$REPO" --json comments \ + --jq '.comments[] | select(.authorAssociation=="OWNER" or .authorAssociation=="MEMBER" or .authorAssociation=="COLLABORATOR") | .body') + if echo "$cmds" | grep -qE '(^|[[:space:]])/gallery-agent[[:space:]]+blacklist([[:space:]]|$)'; then + echo "PR #$pr: blacklist command found" + gh pr edit "$pr" --repo "$REPO" --add-label gallery-agent/blacklisted || true + gh pr close "$pr" --repo "$REPO" --comment "Blacklisted via \`/gallery-agent blacklist\`. This model will not be reproposed." || true + elif echo "$cmds" | grep -qE '(^|[[:space:]])/gallery-agent[[:space:]]+recreate([[:space:]]|$)'; then + echo "PR #$pr: recreate command found" + gh pr close "$pr" --repo "$REPO" --comment "Closed via \`/gallery-agent recreate\`. The next scheduled run will propose this model again." || true + fi + done + + - name: Collect skip URLs for the gallery agent id: open_prs env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + SEARCH: 'chore(model gallery) in:title :robot:' run: | - # Gather model URLs already proposed in any open gallery-agent PR so - # the agent can skip them and not re-propose the same model while a - # previous PR is still waiting to be merged. - urls=$(gh pr list \ - --repo ${{ github.repository }} \ - --state open \ - --search 'chore(model gallery) in:title :robot:' \ - --json body \ - --jq '[.[].body] | join("\n")' \ - | grep -oE 'https://huggingface\.co/[^ )]+' \ - | sort -u || true) - echo "Found URLs from open PRs:" + # Skip set = + # URLs from any open gallery-agent PR (avoid duplicate PRs for the same model while one is pending) + # + URLs from closed PRs carrying the `gallery-agent/blacklisted` label (hard blacklist) + # Plain-closed PRs without the label are ignored — closing a PR is + # not by itself a "never propose again" signal; maintainers must + # opt in via the /gallery-agent blacklist comment command. + urls_open=$(gh pr list --repo "$REPO" --state open --search "$SEARCH" \ + --json body --jq '[.[].body] | join("\n")' \ + | grep -oE 'https://huggingface\.co/[^ )]+' || true) + urls_blacklist=$(gh pr list --repo "$REPO" --state closed --search "$SEARCH" \ + --label gallery-agent/blacklisted \ + --json body --jq '[.[].body] | join("\n")' \ + | grep -oE 'https://huggingface\.co/[^ )]+' || true) + urls=$(printf '%s\n%s\n' "$urls_open" "$urls_blacklist" | sort -u | sed '/^$/d') + echo "Skip URLs:" echo "$urls" { echo "urls<