Skip to content

Clean PR preview

Clean PR preview #40

Workflow file for this run

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/github-script@v3.1.0
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: akalanka47000/pr-preview-action@main
with:
action: remove
pr-number: ${{ env.pr-number }}
umbrella-dir: preview