Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor pr-release.yml to avoid 'await' #3070

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions .github/workflows/pr-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,28 @@ jobs:
id: workflow-info
with:
script: |
# strangely, the array context.payload.workflow_run.pull_requests is
# sometimes empty. So get the data via tha API
const run_id = context.payload.workflow_run.id
console.log(`Querying workflow run data for run_id ${run_id}.`)
const reply = await github.rest.actions.getWorkflowRun({
const run_id = context.payload.workflow_run.id;
console.log(`Querying workflow run data for run_id ${run_id}.`);

github.rest.actions.getWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id
})
if (reply.data.pull_requests) {
core.setOutput('pullRequestNumber', reply.data.pull_requests[0].number)
core.setOutput('sourceHeadSha', reply.data.pull_requests[0].head.sha)
} else {
console.log("Odd, no pull-request-data in workflow data?")
console.log(`reply.data: ${JSON.stringify(reply.data, null, 2)}`)
core.setFailed("Unexpected result from github.rest.actions.getWorkflowRun")
}
.then(reply => {
if (reply.data.pull_requests && reply.data.pull_requests.length > 0) {
core.setOutput('pullRequestNumber', reply.data.pull_requests[0].number);
core.setOutput('sourceHeadSha', reply.data.pull_requests[0].head.sha);
} else {
console.log("Odd, no pull-request-data in workflow data?");
console.log(`reply.data: ${JSON.stringify(reply.data, null, 2)}`);
core.setFailed("Unexpected result from github.rest.actions.getWorkflowRun");
}
})
.catch(error => {
console.error(error);
core.setFailed("Error querying workflow run data: " + error.message);
});
- name: Download artifact from the previous workflow.
if: ${{ steps.workflow-info.outputs.pullRequestNumber != '' }}
id: download-artifact
Expand Down