diff --git a/.github/workflows/ai-generated.yml b/.github/workflows/seerr-labeller.yml similarity index 50% rename from .github/workflows/ai-generated.yml rename to .github/workflows/seerr-labeller.yml index 472cf3196..7a8330555 100644 --- a/.github/workflows/ai-generated.yml +++ b/.github/workflows/seerr-labeller.yml @@ -1,20 +1,23 @@ --- # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: 'AI-generated pull requests' +name: 'Seerr Labeller' on: pull_request_target: types: [labeled, unlabeled, reopened] + issues: + types: [labeled, unlabeled, reopened] -permissions: - pull-requests: read +permissions: {} jobs: ai-generated-support: - if: github.event.label.name == 'ai-generated' || github.event.action == 'reopened' + if: > + github.event_name == 'pull_request_target' && + (github.event.label.name == 'ai-generated' || (github.event.action == 'reopened' && contains(github.event.pull_request.labels.*.name, 'ai-generated'))) runs-on: ubuntu-24.04 concurrency: - group: support-${{ github.event.pull_request.number }} + group: ai-generated-${{ github.event.pull_request.number }} cancel-in-progress: true permissions: pull-requests: write @@ -43,7 +46,7 @@ jobs: retry gh pr close "$NUMBER" -R "$GH_REPO" || true gh pr lock "$NUMBER" -R "$GH_REPO" -r "spam" || true - - name: Reopened or label removed, unlock pull request + - name: Label removed, reopen and unlock pull request if: github.event.action == 'unlabeled' && github.event.label.name == 'ai-generated' shell: bash run: | @@ -57,3 +60,52 @@ jobs: run: | gh pr edit "$NUMBER" -R "$GH_REPO" --remove-label "ai-generated" || true gh pr unlock "$NUMBER" -R "$GH_REPO" || true + + support: + if: > + github.event_name == 'issues' && + (github.event.label.name == 'support' || + (github.event.action == 'reopened' && contains(github.event.issue.labels.*.name, 'support'))) + runs-on: ubuntu-24.04 + concurrency: + group: support-${{ github.event.issue.number }} + cancel-in-progress: true + permissions: + issues: write + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + NUMBER: ${{ github.event.issue.number }} + ISSUE_AUTHOR: ${{ github.event.issue.user.login }} + steps: + - name: Label added, comment and close issue + if: github.event.action == 'labeled' && github.event.label.name == 'support' + shell: bash + env: + BODY: > + :wave: @${{ env.ISSUE_AUTHOR }}, we use the issue tracker exclusively + for bug reports and feature requests. However, this issue appears + to be a support request. Please use our support channels + to get help with Seerr. + + - [Discord](https://discord.gg/seerr) + run: | + retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; } + retry gh issue comment "$NUMBER" -R "$GH_REPO" -b "$BODY" || true + retry gh issue close "$NUMBER" -R "$GH_REPO" || true + gh issue lock "$NUMBER" -R "$GH_REPO" -r "off_topic" || true + + - name: Label removed, reopen and unlock issue + if: github.event.action == 'unlabeled' && github.event.label.name == 'support' + shell: bash + run: | + retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; } + retry gh issue reopen "$NUMBER" -R "$GH_REPO" || true + gh issue unlock "$NUMBER" -R "$GH_REPO" || true + + - name: Remove support label on manual reopen + if: github.event.action == 'reopened' + shell: bash + run: | + gh issue edit "$NUMBER" -R "$GH_REPO" --remove-label "support" || true + gh issue unlock "$NUMBER" -R "$GH_REPO" || true diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml deleted file mode 100644 index c29eb9829..000000000 --- a/.github/workflows/support.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: 'Support requests' - -on: - issues: - types: [labeled, unlabeled, reopened] - -permissions: - issues: read - -jobs: - support: - if: github.event.label.name == 'support' || github.event.action == 'reopened' - runs-on: ubuntu-24.04 - concurrency: - group: support-${{ github.event.issue.number }} - cancel-in-progress: true - permissions: - issues: write - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GH_REPO: ${{ github.repository }} - NUMBER: ${{ github.event.issue.number }} - ISSUE_AUTHOR: ${{ github.event.issue.user.login }} - steps: - - name: Label added, comment and close issue - if: github.event.action == 'labeled' && github.event.label.name == 'support' - shell: bash - env: - BODY: > - :wave: @${{ env.ISSUE_AUTHOR }}, we use the issue tracker exclusively - for bug reports and feature requests. However, this issue appears - to be a support request. Please use our support channels - to get help with Seerr. - - - [Discord](https://discord.gg/seerr) - run: | - retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; } - retry gh issue comment "$NUMBER" -R "$GH_REPO" -b "$BODY" || true - retry gh issue close "$NUMBER" -R "$GH_REPO" || true - gh issue lock "$NUMBER" -R "$GH_REPO" -r "off_topic" || true - - - name: Reopened or label removed, unlock issue - if: github.event.action == 'unlabeled' && github.event.label.name == 'support' - shell: bash - run: | - retry() { n=0; until "$@"; do n=$((n+1)); [ $n -ge 3 ] && break; echo "retry $n: $*" >&2; sleep 2; done; } - retry gh issue reopen "$NUMBER" -R "$GH_REPO" || true - gh issue unlock "$NUMBER" -R "$GH_REPO" || true - - - name: Remove support label on manual reopen - if: github.event.action == 'reopened' - shell: bash - run: | - gh issue edit "$NUMBER" -R "$GH_REPO" --remove-label "support" || true - gh issue unlock "$NUMBER" -R "$GH_REPO" || true