88 - main
99 - " [0-9]+.[0-9]+.x"
1010 workflow_run :
11+ # We need to run the label analysis as workflow_run because the label addition will not trigger it.
12+ # See documentation https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow
1113 workflows : ["Add labels to PR", "Add labels to community PRs"]
1214 types : [completed]
1315
@@ -27,32 +29,13 @@ jobs:
2729 HEAD_REF : ${{ steps.context.outputs.head_ref }}
2830 IS_FORK : ${{ steps.context.outputs.is_fork }}
2931 steps :
30- - name : Get PR number from artifact (workflow_run)
32+ - name : Download PR number artifact
3133 if : github.event_name == 'workflow_run'
32- uses : actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 .1.0
34+ uses : actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 .1.8
3335 with :
34- script : |
35- const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
36- owner: context.repo.owner,
37- repo: context.repo.repo,
38- run_id: ${{ github.event.workflow_run.id }},
39- });
40- const matchArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'pr_number');
41- if (!matchArtifact) {
42- core.setFailed('No pr_number artifact found');
43- return;
44- }
45- const download = await github.rest.actions.downloadArtifact({
46- owner: context.repo.owner,
47- repo: context.repo.repo,
48- artifact_id: matchArtifact.id,
49- archive_format: 'zip',
50- });
51- const fs = require('fs');
52- fs.writeFileSync('${{ github.workspace }}/pr_number.zip', Buffer.from(download.data));
53- - name : Extract PR number artifact
54- if : github.event_name == 'workflow_run'
55- run : unzip pr_number.zip
36+ name : pr_number
37+ github-token : ${{ secrets.GITHUB_TOKEN }}
38+ run-id : ${{ github.event.workflow_run.id }}
5639 - name : Get PR context
5740 id : context
5841 env :
0 commit comments