-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(prepare): ⚡️ improve the prepare-release action
- Loading branch information
1 parent
a5c99cd
commit 98dace8
Showing
1 changed file
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ jobs: | |
- name: Checkout code | ||
uses: actions/[email protected] | ||
with: | ||
ref: ${{ env.BASE_BRANCH }} | ||
fetch-depth: 0 | ||
|
||
- name: Setup nodejs | ||
|
@@ -115,12 +116,20 @@ jobs: | |
direction: 'desc', | ||
}); | ||
core.debug(`resp:\n${JSON.stringify(resp, null, 2)}`); | ||
const pull_number = resp.data[0].number; | ||
if (!pull_number) { | ||
await github.pulls.create(query); | ||
} else { | ||
try { | ||
const pull_number = resp.data[0].number; | ||
core.info(`[info]: pull_number: ${pull_number}`); | ||
query.pull_number = pull_number; | ||
await github.pulls.update(query); | ||
const resp1 = await github.pulls.update(query); | ||
core.info('[info]: Update release PR successfully!'); | ||
core.info(`[info]: See pull request in ${resp1.data.html_url}`); | ||
} catch (err) { | ||
if (err.message === 'Cannot read property \'number\' of undefined') { | ||
core.info('[info]: Not found previous pull request.'); | ||
core.info('[info]: Try to create a new pull request.'); | ||
const resp2 = await github.pulls.create(query); | ||
core.info('[info]: Create release PR successfully!'); | ||
core.info(`[info]: See pull request in ${resp2.data.html_url}`); | ||
} else core.setFailed(`Prepare release PR failed with error:\n${err}`); | ||
} | ||
core.info(`[info]: Prepare release PR successfully!`); |