-
Notifications
You must be signed in to change notification settings - Fork 12
134 lines (120 loc) Β· 4.51 KB
/
main.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
130
131
132
133
134
name: Build Hugo and Deploy
on:
push:
branches:
- main
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
repository_dispatch:
types: [build-hugo]
jobs:
build-deploy:
runs-on: ubuntu-latest
env:
DOCKER_CACHEDIR: /tmp/.docker-cache
HUGO_CACHEDIR: /tmp/.hugo_cache
HUGOMODS_CACHEDIR: /tmp/.hugo_mods_cache
PNPM_CACHEDIR: /tmp/.pnpm-cache
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- name: Cache Docker images
id: cache
uses: ScribeMD/docker-cache@0.5.0
with:
key: docker-${{ runner.os }}-${{ env.DOCKER_ALIYUN_IMG_DEGEST }}
- name: Pull Docker Images
if: steps.cache.outputs.cache-hit != 'true'
run: docker pull fangbinwei/aliyun-oss-website-action:v1
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: 'latest'
extended: true
- name: Build Hugo
run: |
hugo --minify --enableGitInfo
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup Node LTS
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
# - name: Install and run Shiki
# run: |
# export NODE_OPTIONS="--max_old_space_size=7168"
# pnpm install
# pnpm run shiki --silent || true
# # npx rehype-cli public -o --silent || true
#
# - name: Deploy to GitHub Pages
# uses: peaceiris/actions-gh-pages@v4
# with:
# personal_token: ${{ secrets.personal_token }}
# external_repository: eallion/blog
# publish_branch: main
# publish_dir: ./public
# # destination_dir: public
# allow_empty_commit: true
# # commit_message: ${{ GitHub.event.head_commit.message }}
# full_commit_message: ${{ github.event.head_commit.message }}
# #cname: eallion.com
# force_orphan: true
# user_name: 'github-actions[bot]'
# user_email: 'github-actions[bot]@users.noreply.github.com'
#
# - name: Publish to Cloudflare Pages
# uses: cloudflare/wrangler-action@v3
# with:
# apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
# accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
# quiet: true
# command: pages deploy public --project-name=${{ secrets.CLOUDFLARE_PROJECT_NAME }} --commit-dirty=true
- name: Aliyun Actions Docker image degest
run: |
# Check JQ
if ! command -v jq &> /dev/null; then
echo "jq is not installed. Installing..."
sudo apt-get update
sudo apt-get install -y jq
else
echo "jq is already installed."
fi
# Degest
DOCKER_DEGEST=$(curl -s "https://hub.docker.com/v2/namespaces/fangbinwei/repositories/aliyun-oss-website-action/tags/v1" | jq -r '.images[] | select(.architecture == "amd64") | .digest | sub("sha256:"; "")')
echo "DOCKER_ALIYUN_IMG_DEGEST=$DOCKER_DEGEST" >> $GITHUB_ENV
- name: Deploy to Aliyun OSS
uses: docker://fangbinwei/aliyun-oss-website-action:v1
env:
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
BUCKET: eallion-com
ENDPOINT: oss-cn-shanghai.aliyuncs.com
FOLDER: public
SKIP_SETTING: true
INCREMENTAL: true
# - name: Refresh volcengine CDN
# run: |
# curl -s "https://api.github.com/repos/volcengine/volcengine-cli/releases/latest" | grep "browser_download_url.*linux_amd64.zip" | cut -d : -f 2,3 | tr -d \" | wget -O ve.zip -qi -
# unzip -q ve.zip > /dev/null 2>&1
# chmod a+x ./ve
#
# ./ve configure set --profile volcengine-hugo-github-actions --region cn-beijing --endpoint cdn.volcengineapi.com --access-key ${{ secrets.VOLC_ACCESS_KEY }} --secret-key ${{ secrets.VOLC_SECRET_KEY }}
#
# ./ve cdn SubmitRefreshTask --body '{"Type":"dir","Urls":"https://www.eallion.com/"}' > /dev/null 2>&1 || true
- name: Refresh Aliyun ESA
run: |
pnpm install
pnpm run esa
env:
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
ESA_SITE_ID: ${{ secrets.ESA_SITE_ID }}