-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (55 loc) · 1.87 KB
/
pr.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
60
61
62
63
64
65
66
---
on:
pull_request:
jobs:
build_and_publish_preview:
name: Build and Publish Preview
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download mdBook
run: |
set +x
version="v0.4.40"
cd /tmp
archive="mdbook-v0.4.40-x86_64-unknown-linux-gnu.tar.gz"
wget "https://github.com/rust-lang/mdBook/releases/download/v0.4.40/${archive}"
tar xzvf "${archive}"
sudo mv mdbook /usr/bin
mdbook --version
- name: Build
run: mdbook build
- name: Publish to Cloudflare Pages
if: secrets.CLOUDFLARE_API_TOKEN != ''
id: publish
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: 03654dab23842c712e474f409d58f55c
command: pages deploy out --project-name=makerspace-wiki
- name: Add preview URL comment
if: steps.publish.conclusion == 'success'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✨ you may preview these changes at <${{ steps.publish.outputs.deployment-url }}>'
})
- name: Add no preview explanation comment
if: steps.publish.conclusion == 'skipped'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'No preview for you because you created this PR from a fork!'
})