-
Notifications
You must be signed in to change notification settings - Fork 48
40 lines (39 loc) · 1.39 KB
/
clean-preview-environment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This is a post action for deploy-preview-environments
name: Clean preview environment that is just its PR is closed
on:
pull_request:
types:
- closed
concurrency:
group: "github-pages-mirror-for-previews"
cancel-in-progress: true
jobs:
mirror_to_preview_repo:
runs-on: ubuntu-latest
environment:
name: github-pages-mirror-for-previews
env:
SSH_KEY: ${{ secrets.SSH_DEPLOY_KEY_PRIVATE_FOR_ORIGIN_PLANTUML_WASM_REPO }}
PR_NUMBER: ${{ github.event.number }}
steps:
- name: Checkout Source
uses: actions/checkout@v3
- name: Create an empty directory
run: |
EMPTY_DIRECTORY=$(mktemp -d)
echo "EMPTY_DIRECTORY=$EMPTY_DIRECTORY" >> $GITHUB_ENV
shell: bash
- name: Remove preview environment
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ${{ env.EMPTY_DIRECTORY }}
repository-name: "plantuml/plantuml-wasm-dev"
target-folder: "pr-${{ env.PR_NUMBER }}"
ssh-key: ${{ secrets.SSH_DEPLOY_KEY_PRIVATE_FOR_ORIGIN_PLANTUML_WASM_REPO }}
single-commit: true
- name: Remove URL from the comment
if: env.deployment_status == 'success'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-deployed
message: "Preview URL is removed automatically after the PR is closed."