PHAR prefix diff workflow #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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; | |
| } | |
| const runs = runsResponse.data.workflow_runs; | |
| if (runs.length === 0) { | |
| core.setFailed(`No workflow runs found for commit ${commitSha}`); | |
| return; | |
| } | |
| let found = false; | |
| for (const run of runs) { | |
| if (run.status !== "completed" || run.conclusion !== "success") { | |
| continue; | |
| } | |
| if (run.name !== "Compile PHAR" { | |
| continue; | |
| } | |
| const artifactsResp = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: run.id, | |
| }); | |
| const artifact = artifactsResp.data.artifacts.find(a => a.name === expectedArtifactName); | |
| if (artifact) { | |
| core.setOutput("artifact_id", artifact.id); | |
| core.setOutput("run_id", run.id); | |
| found = true; | |
| break; | |
| } | |
| } | |
| if (!found) { | |
| core.setFailed(`No artifact named '${expectedArtifactName}' found for commit ${commitSha}`); | |
| } | |
| - 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 |