Add commands Github workflow
This is primarily for the /backport command that we can use to backport merged PRs. Signed-off-by: Nic Cope <negz@rk0n.org>
This commit is contained in:
parent
f4556df2c6
commit
d3a1443b70
|
@ -0,0 +1,92 @@
|
|||
name: Comment Commands
|
||||
|
||||
on: issue_comment
|
||||
|
||||
jobs:
|
||||
points:
|
||||
runs-on: ubuntu-18.04
|
||||
if: startsWith(github.event.comment.body, '/points')
|
||||
|
||||
steps:
|
||||
- name: Extract Command
|
||||
id: command
|
||||
uses: xt0rted/slash-command-action@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: points
|
||||
reaction: "true"
|
||||
reaction-type: "eyes"
|
||||
allow-edits: "false"
|
||||
permission-level: write
|
||||
- name: Handle Command
|
||||
uses: actions/github-script@v4
|
||||
env:
|
||||
POINTS: ${{ steps.command.outputs.command-arguments }}
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const points = process.env.POINTS
|
||||
|
||||
if (isNaN(parseInt(points))) {
|
||||
console.log("Malformed command - expected '/points <int>'")
|
||||
github.reactions.createForIssueComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: context.payload.comment.id,
|
||||
content: "confused"
|
||||
})
|
||||
return
|
||||
}
|
||||
const label = "points/" + points
|
||||
|
||||
// Delete our needs-points-label label.
|
||||
try {
|
||||
await github.issues.deleteLabel({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: ['needs-points-label']
|
||||
})
|
||||
console.log("Deleted 'needs-points-label' label.")
|
||||
}
|
||||
catch(e) {
|
||||
console.log("Label 'needs-points-label' probably didn't exist.")
|
||||
}
|
||||
|
||||
// Add our points label.
|
||||
github.issues.addLabels({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
labels: [label]
|
||||
})
|
||||
console.log("Added '" + label + "' label.")
|
||||
|
||||
# NOTE(negz): See also backport.yml, which is the variant that triggers on PR
|
||||
# merge rather than on comment.
|
||||
backport:
|
||||
runs-on: ubuntu-18.04
|
||||
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/backport')
|
||||
steps:
|
||||
- name: Extract Command
|
||||
id: command
|
||||
uses: xt0rted/slash-command-action@v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
command: backport
|
||||
reaction: "true"
|
||||
reaction-type: "eyes"
|
||||
allow-edits: "false"
|
||||
permission-level: write
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Open Backport PR
|
||||
uses: zeebe-io/backport-action@v0.0.4
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_workspace: ${{ github.workspace }}
|
||||
version: v0.0.4
|
Loading…
Reference in New Issue