-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (93 loc) · 2.54 KB
/
docs.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
name: docs
# declare default permissions
permissions: read-all
on:
# enable manual run via GitHub UI
workflow_dispatch:
# enable trigger via remote call webhook
repository_dispatch:
types: update-docs
# enable run on "standard" updates to main branch
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CORE: ./core
DOCS: ./docs
DIST: ./docs/dist
SITE: ./docs/site
WORK: ./docs/build/work
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
repository: defenseunicorns/pepr
path: ./core
fetch-depth: 0 # pull history to get version tags
- uses: actions/checkout@v4
with:
repository: defenseunicorns/pepr-docs
path: ./docs
- name: Build the docs!
run: |
SITE=$(realpath "$SITE")
CORE=$(realpath "$CORE")
cd "$DOCS"
npm ci
npm --workspace build run dev -- --site "$SITE" --core "$CORE"
- name: Commit changes to source!
run: |
HUGO_OLD=$(realpath "$SITE/hugo.yaml")
HUGO_NEW=$(realpath "$WORK/hugo.yaml")
CONT_OLD=$(realpath "$SITE/content/en")
CONT_NEW=$(realpath "$WORK/content/en")
rm "$HUGO_OLD"
cp "$HUGO_NEW" "$HUGO_OLD"
rm --recursive --force "$CONT_OLD"
cp --recursive "$CONT_NEW" "$CONT_OLD"
cd "$DOCS"
git config user.name "docs.yml"
git config user.email "<>"
git add --all
if ! git diff-index --quiet HEAD; then
git commit -m "docs.yml"
git push origin main
fi
- name: Upload Artifacts!
uses: actions/upload-artifact@v4
with:
name: dist
retention-days: 1
path: ./docs/dist
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
repository: defenseunicorns/pepr-docs
ref: deploy
path: ./docs
- name: Clear previously deployed content!
run: |
rm -rf "$DIST"
- uses: actions/download-artifact@v4
with:
name: dist
path: ./docs/dist
- name: Deploy the docs!
run: |
BRANCH=deploy
cd "$DOCS"
git config user.name "docs.yml"
git config user.email "<>"
git add --all
git commit -m "docs.yml"
git push origin "$BRANCH"