-
Notifications
You must be signed in to change notification settings - Fork 11
85 lines (79 loc) · 2.82 KB
/
Copy pathdocs.yml
File metadata and controls
85 lines (79 loc) · 2.82 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Docs
on:
push:
branches: [master]
pull_request:
types: [opened, synchronize, reopened, closed]
# All three jobs below deploy to the same Wisp site by pulling its current
# tree, editing one subpath, and redeploying the whole thing (see
# script/publish-docs.sh) — they must not run concurrently or they'll race
# and clobber each other's changes.
concurrency:
group: docs-wisp-deploy
cancel-in-progress: false
permissions:
contents: read
pull-requests: write
jobs:
publish:
name: Publish docs (master)
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: Bogdanp/setup-racket@v1.5
with:
version: stable
- uses: actions/setup-node@v4
with:
node-version: 22
- run: raco pkg install --batch --auto --link --name resyntax
- run: npm install -g wispctl@latest
- run: script/publish-docs.sh publish ""
env:
WISP_APP_PASSWORD: ${{ secrets.WISP_APP_PASSWORD }}
preview:
name: Publish PR preview
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: Bogdanp/setup-racket@v1.5
with:
version: stable
- uses: actions/setup-node@v4
with:
node-version: 22
- run: raco pkg install --batch --auto --link --name resyntax
- run: npm install -g wispctl@latest
- run: script/publish-docs.sh publish "preview/${{ github.event.pull_request.number }}"
env:
WISP_APP_PASSWORD: ${{ secrets.WISP_APP_PASSWORD }}
- name: Comment preview link on PR
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
MARKER="<!-- docs-preview-link -->"
BODY="$MARKER
Docs preview: https://resyntax.notjack.space/preview/${PR_NUMBER}/"
existing_id="$(gh api "repos/$REPO/issues/$PR_NUMBER/comments" --jq ".[] | select(.body | startswith(\"$MARKER\")) | .id" | head -n1)"
if [ -n "$existing_id" ]; then
gh api -X PATCH "repos/$REPO/issues/comments/$existing_id" -f body="$BODY"
else
gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$BODY"
fi
preview-cleanup:
name: Remove PR preview
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g wispctl@latest
- run: script/publish-docs.sh delete "preview/${{ github.event.pull_request.number }}"
env:
WISP_APP_PASSWORD: ${{ secrets.WISP_APP_PASSWORD }}