Skip to content

PHAR prefix diff workflow #1

PHAR prefix diff workflow

PHAR prefix diff workflow #1

# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
name: "PHAR Prefix Diff"
on:
pull_request:
paths:
- 'compiler/**'
- '.github/workflows/phar-prefix-diff.yml'
concurrency:
group: phar-prefix-diff-${{ github.head_ref || github.run_id }} # will be canceled on subsequent pushes in pull requests but not branches
cancel-in-progress: true
jobs:
phar-prefix-diff:
name: "PHAR Prefix Diff"
runs-on: "ubuntu-latest"
timeout-minutes: 60
steps:
- name: Get base commit SHA
id: base
run: echo "base_sha=${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
- name: Find phar-file-checksum from base commit
id: find-artifact
uses: actions/github-script@v7
with:
script: |
const commitSha = `${{ steps.base.outputs.base_sha }}`
const artifactName = "phar-file-checksum"
// Get all workflow runs for this commit
const runs = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 20,
event: "push",
head_sha: commitSha
});
if (runs.data.workflow_runs.length === 0) {
core.setFailed(`No workflow runs found for commit ${commitSha}`);
return;
}
// Pick the latest run (or filter by workflow_id if needed)
const runId = runs.data.workflow_runs[0].id;
// Get artifacts for that run
const artifactsResp = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId
});
const artifact = artifactsResp.data.artifacts.find(a => a.name === artifactName);
if (!artifact) {
core.setFailed(`Artifact '${artifactName}' not found in run ${runId}`);
return;
}
core.setOutput("artifact_id", artifact.id);
core.setOutput("run_id", runId);
- name: Download artifact by ID
uses: actions/download-artifact@v4
with:
artifact-ids: ${{ steps.find-artifact.outputs.artifact_id }}
run-id: ${{ steps.find-artifact.outputs.run_id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
path: ./phar-file-checksum-old.phar