diff --git a/.github/slash-command-dispatch.json b/.github/slash-command-dispatch.json new file mode 100644 index 000000000..85548abe4 --- /dev/null +++ b/.github/slash-command-dispatch.json @@ -0,0 +1,17 @@ +[ + { + "command": "hold", + "permission": "write", + "issue_type": "pull-request" + }, + { + "command": "unhold", + "permission": "write", + "issue_type": "pull-request" + }, + { + "command": "lgtm", + "permission": "write", + "issue_type": "pull-request" + } +] diff --git a/.github/workflows/ops-slash-command-dispatch.yml b/.github/workflows/ops-slash-command-dispatch.yml new file mode 100644 index 000000000..fa71bef48 --- /dev/null +++ b/.github/workflows/ops-slash-command-dispatch.yml @@ -0,0 +1,32 @@ +name: Slash Command Dispatch +on: + issue_comment: + # Type "edited" added here for test purposes. Where possible, avoid + # using to prevent processing unnecessary events. + types: [created, edited] + +jobs: + slashCommandDispatch: + runs-on: ubuntu-latest + permissions: + pull-requests: read + issues: read + steps: + + # Advanced JSON configuration from file + # (These commands do not do anything and are just a reference example) + - name: Slash Command Dispatch (JSON file) + uses: peter-evans/slash-command-dispatch@v5 + id: scd + with: + token: ${{ secrets.PAT_SLASH_COMMAND_DISPATCH }} + reactions: false + config-from-file: .github/slash-command-dispatch.json + + - name: Edit comment with error message + if: steps.scd.outputs.error-message + uses: peter-evans/create-or-update-comment@v5 + with: + comment-id: ${{ github.event.comment.id }} + body: | + > ${{ steps.scd.outputs.error-message }} diff --git a/.github/workflows/ops-slash-command-hold.yml b/.github/workflows/ops-slash-command-hold.yml new file mode 100644 index 000000000..04f894ed8 --- /dev/null +++ b/.github/workflows/ops-slash-command-hold.yml @@ -0,0 +1,21 @@ +name: Handle /hold command + +on: + repository_dispatch: + types: [hold-command] + +jobs: + handle: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v8 + with: + script: | + github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: ['pr-reviews/hold'] + }) diff --git a/.github/workflows/ops-slash-command-unhold.yml b/.github/workflows/ops-slash-command-unhold.yml new file mode 100644 index 000000000..408213067 --- /dev/null +++ b/.github/workflows/ops-slash-command-unhold.yml @@ -0,0 +1,21 @@ +name: Handle /unhold command + +on: + repository_dispatch: + types: [unhold-command] + +jobs: + handle: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v8 + with: + script: | + github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'pr-reviews/hold' + })