|
| 1 | +name: Checkout WP Deps Branch |
| 2 | +description: Checkout a branch for the WP Deps update action |
| 3 | + |
| 4 | +# Based on example https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#using-data-from-the-triggering-workflow |
| 5 | + |
| 6 | +runs: |
| 7 | + using: composite |
| 8 | + steps: |
| 9 | + - name: 'Download artifact' |
| 10 | + uses: actions/github-script@v6 |
| 11 | + with: |
| 12 | + script: | |
| 13 | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 14 | + owner: context.repo.owner, |
| 15 | + repo: context.repo.repo, |
| 16 | + run_id: context.payload.workflow_run.id, |
| 17 | + }); |
| 18 | + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { |
| 19 | + return artifact.name == "pr_number" |
| 20 | + })[0]; |
| 21 | + let download = await github.rest.actions.downloadArtifact({ |
| 22 | + owner: context.repo.owner, |
| 23 | + repo: context.repo.repo, |
| 24 | + artifact_id: matchArtifact.id, |
| 25 | + archive_format: 'zip', |
| 26 | + }); |
| 27 | + const fs = require('fs'); |
| 28 | + const path = require('path'); |
| 29 | + const temp = '${{ runner.temp }}/artifacts'; |
| 30 | + if (!fs.existsSync(temp)){ |
| 31 | + fs.mkdirSync(temp); |
| 32 | + } |
| 33 | + fs.writeFileSync(path.join(temp, 'pr_number.zip'), Buffer.from(download.data)); |
| 34 | +
|
| 35 | + - name: Parse PR Number |
| 36 | + shell: bash |
| 37 | + id: parse-pr-number |
| 38 | + run: | |
| 39 | + unzip pr_number.zip -d "${{ runner.temp }}/artifacts" |
| 40 | + echo "PR_NUMBER=$(cat ${{ runner.temp }}/artifacts/pr/pr_number)" >> $GITHUB_ENV |
| 41 | +
|
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + ref: refs/pull/${{ steps.parse-pr-number.outputs.PR_NUMBER }}/merge |
0 commit comments