Skip to content

Commit

Permalink
ci(prepare): ⚡️ improve the prepare-release action
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-Xu-0100 committed Apr 6, 2021
1 parent a5c99cd commit 98dace8
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
- name: Checkout code
uses: actions/[email protected]
with:
ref: ${{ env.BASE_BRANCH }}
fetch-depth: 0

- name: Setup nodejs
Expand Down Expand Up @@ -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!`);

0 comments on commit 98dace8

Please sign in to comment.