-
Notifications
You must be signed in to change notification settings - Fork 11
57 lines (53 loc) · 1.74 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
name: build-pr
on:
pull_request_target:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
- name: Install Node modules
run: npm install
- name: Eleventy
run: |
cp -f _data/site.json /tmp/site.json
jq '.base_url = "https://igalia.github.io"' \
/tmp/site.json > _data/site.json
npx eleventy \
--output='_site/${{ github.head_ref }}' \
--pathprefix='/wpewebkit.org/${{ github.head_ref }}'
LC_TIME=C date > '_site/${{ github.head_ref }}/.stamp'
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
keep_files: true
- name: Add deploy link
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
// Site preview link already added.
const marker = '\n\n----\n\nSite preview: ';
if (pr.body && pr.body.indexOf(marker) != -1)
return;
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
body: pr.body + marker + 'https://igalia.github.io/wpewebkit.org/${{ github.head_ref }}/',
});