ci: Fixup for 301a7b1e

* Remove debugging code
* Fix path to github-pr-info.txt, which is used when labeled before
  build completes
* Add a check to skip the build if the build is completed but the PR is
  not labeled with Playground
This commit is contained in:
Yuta Saito 2023-12-27 07:47:11 +00:00
parent 0990270c38
commit e81a5453e3
2 changed files with 9 additions and 7 deletions

View File

@ -22,8 +22,7 @@ jobs:
|| (true || (true
&& github.event_name == 'workflow_run' && github.event_name == 'workflow_run'
&& github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.conclusion == 'success'
&& github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.event == 'pull_request')
)
}} }}
steps: steps:
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@ -73,13 +72,11 @@ jobs:
} }
// Workaround for https://github.com/orgs/community/discussions/25220 // Workaround for https://github.com/orgs/community/discussions/25220
console.log(JSON.stringify(context.payload, null, 2));
const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({ const { data: { artifacts } } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
run_id: context.payload.workflow_run.id, run_id: context.payload.workflow_run.id,
}); });
console.log(JSON.stringify(artifacts, null, 2));
const artifact = artifacts.find(artifact => artifact.name == 'github-pr-info'); const artifact = artifacts.find(artifact => artifact.name == 'github-pr-info');
if (!artifact) { if (!artifact) {
throw new Error('Cannot find github-pr-info.txt artifact'); throw new Error('Cannot find github-pr-info.txt artifact');
@ -99,13 +96,18 @@ jobs:
const prNumber = await derivePRNumber(); const prNumber = await derivePRNumber();
console.log(`PR number: ${prNumber}`);
const { data: pr } = await github.rest.pulls.get({ const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner, owner: context.repo.owner,
repo: context.repo.repo, repo: context.repo.repo,
pull_number: prNumber, pull_number: prNumber,
}); });
core.info(`Checking if the PR ${prNumber} is labeled with Playground...`);
if (!pr.labels.some(label => label.name == 'Playground')) {
core.info(`The PR is not labeled with Playground.`);
return;
}
core.info(`Checking if the build is successful for ${pr.head.ref} in ${pr.head.repo.owner.login}/${pr.head.repo.name}...`); core.info(`Checking if the build is successful for ${pr.head.ref} in ${pr.head.repo.owner.login}/${pr.head.repo.name}...`);
const buildRun = await findSuccessfuBuildRun(pr); const buildRun = await findSuccessfuBuildRun(pr);
if (!buildRun) { if (!buildRun) {

View File

@ -163,12 +163,12 @@ jobs:
# Workaround for https://github.com/orgs/community/discussions/25220 # Workaround for https://github.com/orgs/community/discussions/25220
- name: Save Pull Request number - name: Save Pull Request number
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
run: echo "${{ github.event.pull_request.number }}" >> ./github-pr-info.txt run: echo "${{ github.event.pull_request.number }}" >> ${{ github.workspace }}/github-pr-info.txt
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: ${{ github.event_name == 'pull_request' }} if: ${{ github.event_name == 'pull_request' }}
with: with:
name: github-pr-info name: github-pr-info
path: github-pr-info.txt path: ${{ github.workspace }}/github-pr-info.txt
defaults: defaults:
run: run: