-
-
Notifications
You must be signed in to change notification settings - Fork 74
129 lines (112 loc) · 3.51 KB
/
deploy-pages.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
name: Deploy documentation
on:
push:
branches:
- main
- docs-snapshot
- docs-ci-test
workflow_dispatch: {}
release:
types:
- released
concurrency:
group: "pages-cf"
cancel-in-progress: true
jobs:
snapshot-docs:
name: Snapshot documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
# Run on releases only
if: ${{ github.event.release }}
with:
ref: ${{ github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Merge with existing branch
# Run on releases only
if: ${{ github.event.release }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@nadena.dev"
git merge -s ours origin/docs-snapshot
git push origin HEAD:docs-snapshot
build-docs:
name: Build documentation (latest release)
uses: bdunderscore/modular-avatar/.github/workflows/build-test-docs.yml@main
needs:
- snapshot-docs
with:
ref: docs-snapshot
build-docs-dev:
name: Build documentation (main branch)
uses: bdunderscore/modular-avatar/.github/workflows/build-test-docs.yml@main
with:
ref: main
path: dev
artifact: docs-dev
deploy-docs:
name: Deploy documentation
needs:
- build-docs
- build-docs-dev
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Download artifact (tagged)
uses: actions/download-artifact@v4
with:
name: docs
path: docs/build
- name: Download artifact (latest)
uses: actions/download-artifact@v4
with:
name: docs-dev
path: docs/build/dev
- name: Dump file listing
run: |
ls -lR docs/build
- name: Unpack documentation
run: |
mkdir -p docs-site~/public/dev
tar -xf docs/build/docs.tar -C docs-site~/public
tar -xf docs/build/dev/docs.tar -C docs-site~/public/dev
- name: Setup yarn 2.0
run: |
corepack enable
corepack prepare yarn@stable --activate
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(cd docs-site~; yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-site-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-site-
- name: Build CF site
run: |
cd docs-site~
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: deploy --name modular-avatar-docs
workingDirectory: docs-site~
- name: Purge cache
uses: nathanvaughn/actions-cloudflare-purge@992cc4e96422fb8ddf077281678373fe41e7736c
continue-on-error: true
with:
cf_zone: ${{ secrets.CF_ZONE_ID }}
cf_auth: ${{ secrets.CF_API_TOKEN }}