Skip to content

Commit 87f621f

Browse files
authored
Split docs preview workflows (#770)
1 parent 8604076 commit 87f621f

2 files changed

Lines changed: 35 additions & 30 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docs Preview Cleanup
2+
3+
on:
4+
pull_request:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
cleanup:
13+
name: Cleanup documentation preview
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v6
17+
with:
18+
ref: gh-pages
19+
fetch-depth: 0
20+
21+
- name: Remove documentation preview
22+
run: |
23+
target="previews/PR${{ github.event.pull_request.number }}"
24+
if [ -d "$target" ]; then
25+
rm -rf "$target"
26+
git config user.name "github-actions[bot]"
27+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
28+
git add -A
29+
git commit -m "Remove preview for PR #${{ github.event.pull_request.number }} [skip ci]"
30+
git push origin HEAD:gh-pages
31+
else
32+
echo "No preview directory to clean."
33+
fi

.github/workflows/docs-preview.yml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
name: Docs Preview
22

33
on:
4-
pull_request:
5-
types:
6-
- closed
74
workflow_run:
85
workflows:
96
- CI
107
types:
118
- completed
9+
branches-ignore:
10+
- master
1211

1312
permissions:
14-
actions: read
15-
contents: write
1613
issues: write
1714
pull-requests: read
1815

1916
jobs:
2017
comment:
2118
if: >-
22-
github.event_name == 'workflow_run' &&
2319
github.event.workflow_run.event == 'pull_request' &&
2420
github.event.workflow_run.conclusion == 'success'
2521
name: Comment documentation preview URL
@@ -86,27 +82,3 @@ jobs:
8682
body,
8783
});
8884
}
89-
90-
cleanup:
91-
if: github.event_name == 'pull_request' && github.event.action == 'closed'
92-
name: Cleanup documentation preview
93-
runs-on: ubuntu-latest
94-
steps:
95-
- uses: actions/checkout@v6
96-
with:
97-
ref: gh-pages
98-
fetch-depth: 0
99-
100-
- name: Remove documentation preview
101-
run: |
102-
target="previews/PR${{ github.event.pull_request.number }}"
103-
if [ -d "$target" ]; then
104-
rm -rf "$target"
105-
git config user.name "github-actions[bot]"
106-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
107-
git add -A
108-
git commit -m "Remove preview for PR #${{ github.event.pull_request.number }} [skip ci]"
109-
git push origin HEAD:gh-pages
110-
else
111-
echo "No preview directory to clean."
112-
fi

0 commit comments

Comments
 (0)