Skip to content

Commit e745a76

Browse files
committed
Separate preview + remove-preview workflows
1 parent 02fa4b1 commit e745a76

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

.github/workflows/preview.yml

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
concurrency:
1111
group: docs
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
build-and-preview:
1519
if: github.event.action == 'opened' || github.event.action == 'synchronize'
@@ -70,41 +74,11 @@ jobs:
7074
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
7175
token: ${{ secrets.GITHUB_TOKEN }}
7276

73-
comment-preview-url:
74-
needs: build-and-preview
75-
if: needs.build-and-preview.result == 'success'
76-
runs-on: ubuntu-latest
77-
steps:
78-
- name: Comment Preview URL
77+
- name: Comment preview URL
7978
uses: thollander/actions-comment-pull-request@v2
8079
with:
8180
message: |
8281
<!-- preview-url-comment -->
8382
Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }}
8483
Please avoid using the search feature and navigation bar in PR previews!
8584
comment_tag: preview-url-comment
86-
env:
87-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88-
89-
delete-preview-directory:
90-
if: github.event.action == 'closed' || github.event.pull_request.merged == true
91-
runs-on: ubuntu-latest
92-
steps:
93-
- name: Checkout gh-pages branch
94-
uses: actions/checkout@v4
95-
with:
96-
ref: gh-pages
97-
98-
- name: Remove PR Preview Directory
99-
run: |
100-
PR_NUMBER=${{ github.event.pull_request.number }}
101-
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
102-
git config --global user.name "github-actions[bot]"
103-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
104-
git pull origin gh-pages
105-
rm -rf ${PREVIEW_DIR}
106-
git add .
107-
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
108-
git push
109-
env:
110-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Remove PR previews
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
delete-preview-directory:
13+
if: github.event.action == 'closed' || github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout gh-pages branch
17+
uses: actions/checkout@v4
18+
with:
19+
ref: gh-pages
20+
21+
- name: Remove PR Preview Directory
22+
run: |
23+
PR_NUMBER=${{ github.event.pull_request.number }}
24+
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
25+
git config --global user.name "github-actions[bot]"
26+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
27+
git pull origin gh-pages
28+
rm -rf ${PREVIEW_DIR}
29+
git add .
30+
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
31+
git push

0 commit comments

Comments
 (0)