Remove signoff
action as it will not work with forked repositories
This commit is contained in:
committed by
Àngel Ollé Blázquez
parent
dc71975f27
commit
9e15e95001
47
.github/workflows/signoff_mr.yml
vendored
47
.github/workflows/signoff_mr.yml
vendored
@ -1,47 +0,0 @@
|
|||||||
on: issue_comment
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/github-script@v5
|
|
||||||
if: github.event.action == 'created'
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
const isValidSignOff = (
|
|
||||||
context.payload.action === 'created' &&
|
|
||||||
context.payload.issue.pull_request &&
|
|
||||||
context.payload.comment.user.id === context.payload.issue.user.id &&
|
|
||||||
context.payload.comment.body === '/signoff'
|
|
||||||
)
|
|
||||||
if (!isValidSignOff) return
|
|
||||||
const pr = await github.pulls.get({
|
|
||||||
...context.repo,
|
|
||||||
pull_number: context.payload.issue.number
|
|
||||||
})
|
|
||||||
const commits = await github.pulls.listCommits({
|
|
||||||
...context.repo,
|
|
||||||
pull_number: context.payload.issue.number
|
|
||||||
})
|
|
||||||
const baseCommit = await github.git.getCommit({
|
|
||||||
...context.repo,
|
|
||||||
commit_sha: pr.data.head.sha
|
|
||||||
})
|
|
||||||
const tree = await github.git.getTree({
|
|
||||||
...context.repo,
|
|
||||||
tree_sha: baseCommit.data.tree.sha
|
|
||||||
})
|
|
||||||
const commitLines = commits.data.map(item => `- ${item.sha.slice(0, 6)}: ${item.commit.message}`).join('\n')
|
|
||||||
const header = `I, @${context.payload.comment.user.login}, hereby signoff on these commits:`
|
|
||||||
const newCommit = await github.git.createCommit({
|
|
||||||
...context.repo,
|
|
||||||
message: `${header}\n\n${commitLines}`,
|
|
||||||
tree: tree.data.sha,
|
|
||||||
parents: [pr.data.head.sha]
|
|
||||||
})
|
|
||||||
await github.git.updateRef({
|
|
||||||
...context.repo,
|
|
||||||
ref: `heads/${pr.data.head.ref}`,
|
|
||||||
sha: newCommit.data.sha
|
|
||||||
})
|
|
Reference in New Issue
Block a user