-
-
Notifications
You must be signed in to change notification settings - Fork 32
42 lines (35 loc) · 1.29 KB
/
delete_pr_built_doc.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
name: Delete docs built with PR
on:
pull_request:
branches: [ "3.9" ]
types:
- closed # PR closed
jobs:
delete_pr_docs:
runs-on: ubuntu-latest
steps:
- name: Prepare environment variables
run: |
ref=${GITHUB_REF#refs/pull/}
pr_num=${ref%/merge}
echo "::set-env name=PR_NUM::${pr_num}"
echo "::set-env name=PR_BUILD_ID::${GITHUB_BASE_REF}/${pr_num}"
echo "::set-env name=DOCS_BASE_DIR::build/html"
echo "::set-env name=DOCS_OUTPUT_DIR::build/html/${GITHUB_BASE_REF}/${pr_num}"
- name: Checkout GitHub Pages
uses: actions/checkout@v2
with:
ref: gh-pages
path: build/html
- name: Delete docs
run: |
cd ${GITHUB_WORKSPACE}/${DOCS_BASE_DIR}
pwd
git rm -r ${GITHUB_WORKSPACE}/${DOCS_OUTPUT_DIR}
git config --local user.name "Autobuild bot on GitHub Actions"
git config --local user.email "[email protected]"
pwd
git add .
# if [ $(git status -s | wc -l) -eq 0 ]; then echo "nothing to commit"; exit 0; fi
git commit -m "Delete docs, branch: ${GITHUB_BASE_REF} pr_num: ${PR_NUM}"
git push --quiet "https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" gh-pages:gh-pages