-
Notifications
You must be signed in to change notification settings - Fork 199
133 lines (114 loc) · 3.82 KB
/
docs-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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Deploy preview for PR
on:
pull_request:
jobs:
add_label:
runs-on: ubuntu-latest
outputs:
has_label: ${{ steps.check-labels.outputs.result }}
steps:
- name: Check if label is present
id: check-labels
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (labels.includes('documentation')) {
return true;
}
// Fetch the list of files changed in the PR
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
per_page: 100
});
// Check if any file is within the 'docs' folder
const docsChanged = files.some(file => file.filename.startsWith('docs/'));
return docsChanged;
- name: Add label if not present
if: steps.check-labels.outputs.result == 'true'
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labels = context.payload.pull_request.labels.map(label => label.name);
if (!labels.includes('documentation')) {
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['documentation']
})
}
build_preview:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup toolchain
uses: dtolnay/[email protected]
- uses: Swatinem/rust-cache@v2
with:
key: x86_64-unknown-linux-gnu
cache-on-failure: false
save-if: false
- name: Install Yarn dependencies
uses: ./.github/actions/setup
- name: Install wasm-bindgen-cli
uses: taiki-e/install-action@v2
with:
tool: [email protected]
- name: Install wasm-opt
run: |
npm i wasm-opt -g
- name: Query active docs versions
run: yarn workspace docs version::stables
- name: Build docs
env:
ENV: staging # not really a secret, it will show in the footer anyway
run: yarn workspaces foreach -Rpt --from docs run build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: ./docs/build/
retention-days: 3
deploy_preview:
needs: [build_preview, add_label]
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: needs.add_label.outputs.has_label == 'true'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download built docs
uses: actions/download-artifact@v4
with:
name: docs
path: ./docs/build
- name: Deploy to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: './docs/build'
github-token: ${{ secrets.GITHUB_TOKEN }}
enable-github-deployment: false
deploy-message: "Deploy from GitHub Actions for PR ${{ github.event.number }}"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
add_comment:
needs: [deploy_preview]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Tag dev rel in comment
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
FYI @noir-lang/developerrelations on Noir doc changes.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}