Skip to content

Commit feb46b4

Browse files
committed
PHAR prefix diff workflow
1 parent 803aacd commit feb46b4

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
3+
name: "PHAR Prefix Diff"
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- 'compiler/**'
9+
- '.github/workflows/phar-prefix-diff.yml'
10+
11+
concurrency:
12+
group: phar-prefix-diff-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
13+
cancel-in-progress: true
14+
15+
jobs:
16+
phar-prefix-diff:
17+
name: "PHAR Prefix Diff"
18+
19+
runs-on: "ubuntu-latest"
20+
timeout-minutes: 60
21+
22+
steps:
23+
- name: Get base commit SHA
24+
id: base
25+
run: echo "base_sha=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
26+
27+
- name: Find phar-file-checksum from base commit
28+
id: find-artifact
29+
uses: actions/github-script@v7
30+
with:
31+
script: |
32+
const commitSha = `${{ steps.base.outputs.base_sha }}`
33+
const artifactName = "phar-file-checksum"
34+
35+
// Get all workflow runs for this commit
36+
const runs = await github.rest.actions.listWorkflowRunsForRepo({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
per_page: 20,
40+
event: "push",
41+
head_sha: commitSha
42+
});
43+
44+
if (runs.data.workflow_runs.length === 0) {
45+
core.setFailed(`No workflow runs found for commit ${commitSha}`);
46+
return;
47+
}
48+
49+
// Pick the latest run (or filter by workflow_id if needed)
50+
const runId = runs.data.workflow_runs[0].id;
51+
52+
// Get artifacts for that run
53+
const artifactsResp = await github.rest.actions.listWorkflowRunArtifacts({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
run_id: runId
57+
});
58+
59+
const artifact = artifactsResp.data.artifacts.find(a => a.name === artifactName);
60+
if (!artifact) {
61+
core.setFailed(`Artifact '${artifactName}' not found in run ${runId}`);
62+
return;
63+
}
64+
65+
core.setOutput("artifact_id", artifact.id);
66+
core.setOutput("run_id", runId);
67+
68+
- name: Download artifact by ID
69+
uses: actions/download-artifact@v4
70+
with:
71+
artifact-ids: ${{ steps.find-artifact.outputs.artifact_id }}
72+
run-id: ${{ steps.find-artifact.outputs.run_id }}
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
path: ./phar-file-checksum-old.phar

0 commit comments

Comments
 (0)