Deploy info run #155
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
| name: Deploy info run | |
| # This is a separate workflow which runs after `deploy-info.yml` | |
| # because that one cannot have write permissions to the fork's target repo | |
| # due to GitHub Actions restrictions. | |
| on: | |
| workflow_run: | |
| workflows: [ Deploy info ] | |
| types: [ completed ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| deploy-info: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| if: github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Download artifact | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.payload.workflow_run.id, | |
| }); | |
| const matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
| return artifact.name == "pr_number" | |
| })[0]; | |
| const download = await github.rest.actions.downloadArtifact({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| artifact_id: matchArtifact.id, | |
| archive_format: 'zip', | |
| }); | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const temp = '${{ runner.temp }}/artifacts'; | |
| if (!fs.existsSync(temp)){ | |
| fs.mkdirSync(temp); | |
| } | |
| fs.writeFileSync(path.join(temp, 'pr_number.zip'), Buffer.from(download.data)); | |
| - name: Unzip artifact | |
| run: unzip "${{ runner.temp }}/artifacts/pr_number.zip" -d "${{ runner.temp }}/artifacts" | |
| - uses: actions/checkout@v5 | |
| - name: Push to internal branch | |
| run: | | |
| pr_number=$(cat "${{ runner.temp }}/artifacts/pr_number") | |
| git fetch origin ${{ github.event.workflow_run.head_sha }} | |
| git push origin ${{ github.event.workflow_run.head_sha }}:refs/heads/deploy/${pr_number} --force |