chore: correct the update PR script

This commit is contained in:
Ika 2021-10-17 03:58:07 +00:00 committed by GitHub
parent 1eb1a962e7
commit b03e095fb0

View File

@ -41,12 +41,13 @@ jobs:
script: | script: |
const {owner, repo} = context.repo const {owner, repo} = context.repo
const branch = 'github-actions-auto-update' const branch = 'github-actions-auto-update'
const head = `${owner}:${branch}`
const title = 'docs(readme): update emoji-cheat-sheet' const title = 'docs(readme): update emoji-cheat-sheet'
const branchesResult = await github.repos.listBranches({ owner, repo }) const branchesResult = await github.repos.listBranches({ owner, repo })
if (branchesResult.status !== 200 || !branchesResult.data.find(({ name }) => name === branch)) { if (branchesResult.status !== 200 || !branchesResult.data.find(({ name }) => name === branch)) {
return return
} }
const prsResult = await github.pulls.list({ owner, repo, head: branch, state: 'open' }) const prsResult = await github.pulls.list({ owner, repo, head, state: 'open' })
if (prsResult.status === 200 && prsResult.data.length === 0) { if (prsResult.status === 200 && prsResult.data.length === 0) {
await github.pulls.create({ owner, repo, head: branch, title, base: 'master' }) await github.pulls.create({ owner, repo, head, title, base: 'master' })
} }