-
Notifications
You must be signed in to change notification settings - Fork 21
106 lines (99 loc) · 3.18 KB
/
gitsite.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
# Workflow for building and deploying a GitSite repo to GitHub Pages
name: Build liaoxuefeng.com
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
pull_request:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- name: Setup Env
run: |
echo "RELEASE_AT=`echo ${{ github.event.head_commit.timestamp }} | sed 's/[:+]/-/g'`" >> "$GITHUB_ENV"
echo "SHORT_SHA=`echo ${{ github.sha }} | cut -c1-7`" >> "$GITHUB_ENV"
- name: Print Env
run: |
echo ${{ env.RELEASE_AT }}
echo ${{ env.SHORT_SHA }}
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install GitSite
run:
npm install gitsite-cli -g
- name: Build with GitSite
run:
# set output dir to '_site' for pages jobs:
gitsite-cli build -o _site
- name: Configure Pages
uses: actions/configure-pages@v5
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
- name: Zip Generated Site
run:
cd _site && zip -r ../site.zip * && cd ..
- name: Release Zip
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: site.zip
tag: ${{ github.ref }}.${{ github.sha }}
release_name: site-source.${{ env.SHORT_SHA }}
body: Site source code including HTML, styles, scripts, images, etc.
overwrite: true
- name: Sync To Aliyun
uses: michaelliao/sync-s3-compatible-action@v2
env:
SYNC_OPT_UNUSED: delete
SYNC_TYPE: aliyun
SYNC_REGION: cn-hangzhou
SYNC_BUCKET: ${{ secrets.OSS_BUCKET }}
SYNC_ACCESS_ID: ${{ secrets.OSS_ACCESS_ID }}
SYNC_ACCESS_SECRET: ${{ secrets.OSS_ACCESS_SECRET }}
- name: Sync To QCloud
uses: michaelliao/sync-s3-compatible-action@v2
env:
SYNC_OPT_UNUSED: delete
SYNC_TYPE: qcloud
SYNC_REGION: ap-shanghai
SYNC_BUCKET: ${{ secrets.COS_BUCKET }}
SYNC_ACCESS_ID: ${{ secrets.COS_ACCESS_ID }}
SYNC_ACCESS_SECRET: ${{ secrets.COS_ACCESS_SECRET }}
- name: Sync To Baidu Cloud
uses: michaelliao/sync-s3-compatible-action@v2
env:
SYNC_OPT_UNUSED: delete
SYNC_TYPE: baidu
SYNC_REGION: su
SYNC_BUCKET: ${{ secrets.BOS_BUCKET }}
SYNC_ACCESS_ID: ${{ secrets.BOS_ACCESS_ID }}
SYNC_ACCESS_SECRET: ${{ secrets.BOS_ACCESS_SECRET }}
# Deployment job
deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4