-
Notifications
You must be signed in to change notification settings - Fork 267
112 lines (92 loc) · 3.66 KB
/
Copy pathdeploy-manual.yml
File metadata and controls
112 lines (92 loc) · 3.66 KB
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
name: Deploy main site to GitHub Pages
permissions:
contents: write
pages: write
on:
# for local PR builds esp. builds in forked repositories
workflow_dispatch:
jobs:
build:
name: Build Site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: latest
cache: npm
- name: Install Dependencies
run: npm ci
- name: Get pages deployment URL
run: |
pages_url=$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.html_url')
url=$(echo $pages_url|cut -d'/' -f 1)//$(echo $pages_url|cut -d'/' -f 3)
base_url=$(echo $pages_url|cut -d'/' -f 4)
echo "url=$url" >> "$GITHUB_ENV"
echo "base_url=$base_url" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Patch docusaurus.config.ts
run: |
sed -E -i "s^url:(..*)^url: '${{ env.url }}',^g" docusaurus.config.ts
sed -E -i "s^baseUrl:(..*)^baseUrl: '/${{ env.base_url }}',^g" docusaurus.config.ts
- name: Fetch contributors details from GitHub API
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: node src/_scripts/_fetch-contributors-details.js
- name: Export drawios to svgs
run: DOCKER=1 node src/_scripts/_export-drawios.js
- name: Build Website
run: npm run build
- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: build
deploy:
name: Deploy Site
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
path: __build__
- name: Set up Git
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Switch to Pages Branch
run: |
gh_pages_branch=$(gh api "repos/$GITHUB_REPOSITORY/pages" --jq '.source.branch')
git fetch origin $gh_pages_branch
git checkout $gh_pages_branch
echo "gh_pages_branch=$gh_pages_branch" >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Drop Previous Content
run: |
shopt -s extglob
rm -rf !(@*|__build__)
- name: Extract Build Content
run: |
if [[ -d "__build__" && "$(ls -A __build__)" ]]; then
mv __build__/* ./
tar -xvf github-pages/artifact.tar
rm github-pages/artifact.tar
rm -rf __build__
else
echo "No build files found. Skipping move step."
fi
- name: Commit and Push Changes
run: |
git add -A
if [[ "$(git status -s)" ]]; then
git commit -m "site build ➝ gh pages"
git push -f origin ${{ env.gh_pages_branch }}
fi