@@ -18,11 +18,41 @@ jobs:
1818 steps :
1919 - name : Checkout repository
2020 uses : actions/checkout@v4
21+
22+ - name : Download branch name artifact
23+ uses : actions/github-script@v7
24+ with :
25+ script : |
26+ let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
27+ owner: context.repo.owner,
28+ repo: context.repo.repo,
29+ run_id: context.payload.workflow_run.id,
30+ });
31+ let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
32+ return artifact.name == "branch_name"
33+ })[0];
34+ let download = await github.rest.actions.downloadArtifact({
35+ owner: context.repo.owner,
36+ repo: context.repo.repo,
37+ artifact_id: matchArtifact.id,
38+ archive_format: 'zip',
39+ });
40+ const fs = require('fs');
41+ const path = require('path');
42+ const temp = '${{ runner.temp }}/artifacts';
43+ if (!fs.existsSync(temp)){
44+ fs.mkdirSync(temp);
45+ }
46+ fs.writeFileSync(path.join(temp, 'branch_name.zip'), Buffer.from(download.data));
47+
48+ - name : Unzip branch name artifact
49+ run : unzip branch_name.zip -d "${{ runner.temp }}/artifacts"
50+
2151 - name : Trigger other workflows
2252 run : |
2353 for workflow in .github/workflows/*.yml; do
2454 if [[ ! " ${EXCLUDE_WORKFLOWS[@]} " =~ " $(basename $workflow) " ]]; then
25- echo "Triggering workflow run $(basename $workflow)"
26- gh workflow run $(basename $workflow)
55+ echo "Triggering workflow run $(basename $workflow) for $(cat ${{ runner.temp }}/artifacts/branch_name) "
56+ gh workflow run $(basename $workflow) --ref $(cat ${{ runner.temp }}/artifacts/branch_name)
2757 fi
2858 done
0 commit comments