Clean PR preview #127
This file contains 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: Clean PR preview | |
on: | |
workflow_run: | |
workflows: ["Close PR"] | |
types: | |
- completed | |
jobs: | |
close-preview: | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: "Download PR number" | |
uses: actions/[email protected] | |
with: | |
script: | | |
var artifacts = await github.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "prnumber" | |
})[0]; | |
var download = await github.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/prnumber.zip', Buffer.from(download.data)); | |
- run: | | |
unzip prnumber.zip | |
echo "pr-number=$(cat prnumber.txt)" >> "$GITHUB_ENV" | |
shell: bash | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: 3.x | |
- name: Clean preview | |
uses: access-nri/[email protected] | |
with: | |
action: remove | |
pr-number: ${{ env.pr-number }} | |