From bbc2250bf5df2a5390905e43614b128099a52f99 Mon Sep 17 00:00:00 2001 From: Ika Date: Thu, 9 Jul 2020 22:18:09 +0800 Subject: [PATCH] chore: fix auto-update script --- .github/workflows/update.yml | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 34e294f..04b9490 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -41,26 +41,12 @@ jobs: script: | const {owner, repo} = context.repo const branch = 'github-actions-auto-update' - const {status: branchStatus} = await github.repos.getBranch({ - owner, - repo, - branch, - }) - if (branchStatus !== 200) { + const title = 'docs(readme): update emoji-cheat-sheet' + const branchesResult = await github.repos.listBranches({ owner, repo }) + if (branchesResult.status !== 200 || !branchesResult.data.find(({ name }) => name === branch)) { return } - const {status, data: prs} = await github.pulls.list({ - owner, - repo, - head: branch, - state: 'open', - }) - if (status === 200 && prs.length === 0) { - await github.pulls.create({ - owner, - repo, - head: branch, - title: 'docs(readme): update emoji-cheat-sheet', - base: 'master', - }) + const prsResult = await github.pulls.list({ owner, repo, head: branch, state: 'open' }) + if (prsResult.status === 200 && prsResult.data.length === 0) { + await github.pulls.create({ owner, repo, head: branch, title, base: 'master' }) }