-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (53 loc) · 1.92 KB
/
wf-cleanup-gh-pages.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Cleanup GitHub Pages Pull Request
on:
workflow_call:
inputs:
GITHUB_PAGES_BRANCH:
description: "The branch that GitHub Pages is configured with."
type: string
default: "gh-pages"
required: false
ROOT_PATH:
description: "The GitHub Pages root deployment path."
type: string
default: "docs"
required: false
PR_PATH:
description: "The deployment path relative to the GitHub Pages root."
type: string
required: false
secrets:
GITHUB_ACCESS_TOKEN:
description: "GitHub Token used to access the repository."
required: true
jobs:
cleanup-gh-pages-pr:
name: Cleanup GitHub Pages Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
persist-credentials: false
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
ref: ${{ inputs.GITHUB_PAGES_BRANCH }}
- name: Remove ${{ inputs.ROOT_PATH }}/${{ inputs.PR_PATH || github.head_ref }} Folder
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "GitHub Actions"
if [ -d "$ROOT_PATH/$PR_PATH" ]; then
echo "Directory $ROOT_PATH/$PR_PATH exists"
rm -rf $ROOT_PATH/$PR_PATH
git add $ROOT_PATH/$PR_PATH
git commit -m "[GitHub Actions] Remove Pull Request GitHub Pages build for branch $ROOT_PATH/$PR_PATH [skip ci]"
else
echo "Directory $ROOT_PATH/$PR_NAME does not exists. Skipping deletion."
fi
env:
ROOT_PATH: ${{ inputs.ROOT_PATH }}
PR_PATH: ${{ inputs.PR_PATH || github.head_ref }}
- name: Push Changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
branch: ${{ inputs.GITHUB_PAGES_BRANCH }}