Skip to content

Commit

Permalink
approve & unapprove
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Nov 26, 2024
1 parent b87b57c commit 36b3796
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/command-runner/merge.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ module.exports = async ({ github, context, command, core, commentId }) => {

if (command === 'merge') {
console.log('Run merge')
await github.rest.pulls.submitReview({
...context.repo,
pull_number: context.issue.number,
event: 'APPROVE',
})
await github.rest.pulls.update({
...context.repo,
pull_number: context.issue.number,
Expand All @@ -18,6 +23,12 @@ module.exports = async ({ github, context, command, core, commentId }) => {

if (command === 'cancel-merge') {
console.log('Run cancel-merge')
await github.rest.pulls.submitReview({
...context.repo,
pull_number: context.issue.number,
event: 'REQUEST_CHANGES',
body: 'Dismissed'
})
await github.rest.pulls.update({
...context.repo,
pull_number: context.issue.number,
Expand All @@ -28,4 +39,4 @@ module.exports = async ({ github, context, command, core, commentId }) => {
core.info('Auto-merge disabled')
return
}
}
}
6 changes: 6 additions & 0 deletions .github/workflows/command-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,14 @@ jobs:
node-version: 18.x
cache: 'yarn'
- run: yarn --immutable
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const script = require('.github/command-runner/runOrBump.cjs')
const { command, args, env, commentId } = ${{ needs.check.outputs.result }}
Expand Down

0 comments on commit 36b3796

Please sign in to comment.