-
Notifications
You must be signed in to change notification settings - Fork 352
70 lines (60 loc) · 2.17 KB
/
docs-pr.yaml
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
name: Docs Preview and Link Check
on:
pull_request:
paths:
- "docs/**"
branches:
- master
push:
paths:
- "docs/**"
jobs:
# This job name kept short because it's used in the preview URL
preview:
name: Docs PR - Publish preview and check links
runs-on: ubuntu-20.04
steps:
- name: Check-out
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: docs
ruby-version: '3.2'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Build latest
id: build-latest
working-directory: docs
run: bundle exec jekyll build --config _config.yml -d _site/ --verbose
- name: Overlay PR message on each page
working-directory: docs/_site
run: |
PR_URL=${{ github.event.pull_request.html_url }}
PR_NUMBER=${{ github.event.pull_request.number }}
html_files=$(find . -name '*.html')
for file in $html_files; do
sed -i -e "s|\(.*\)\(</body>\)|<div style=\"position: fixed; top: 5px; left: 5px; padding: 3px; background-color: #e8ac07; font-weight: bold; z-index: 9999; box-shadow: 0 0 10px rgba(0,0,0,0.5);\">ℹ️ This is a preview of PR <a href=\"$PR_URL\" style=\"color: black;\">#$PR_NUMBER</a></div>\n\1\2|" $file
done
- name: Publish preview site
uses: afc163/surge-preview@v1
id: preview_step
with:
surge_token: ${{ secrets.SURGE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
dist: docs/_site
failOnError: true
teardown: true
build: |
echo Deploying preview to surge.sh
- name: Get the preview_url
run: echo "url => https://${{ steps.preview_step.outputs.preview_url }}"
- name: Check links
id: lychee
uses: lycheeverse/[email protected]
with:
args: docs/_site --no-progress --exclude-file=docs/.lycheeignore
fail: true
jobSummary: true
format: markdown
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}