-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (129 loc) · 3.66 KB
/
Copy pathdeploy.yml
File metadata and controls
149 lines (129 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Deploy AIHeadline.news
on:
push:
branches: [main]
schedule:
- cron: '30 0 * * *' # 每天 UTC 00:30,即北京时间 08:30
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
env:
HUGO_VERSION: 0.150.0
jobs:
build:
name: Build site
runs-on: ubuntu-latest
permissions:
contents: read
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: false
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Fetch latest briefing archive snapshot
run: ./.github/scripts/update-source-news.sh
env:
SOURCE_NEWS_FETCH_RETRIES: 4
- name: Restore Hugo cache
uses: actions/cache@v5
with:
path: ./.cache/hugo_cache
key: ${{ runner.os }}-hugo-${{ env.HUGO_VERSION }}-${{ hashFiles('hugo.toml', 'go.mod', 'go.sum', 'package*.json') }}
restore-keys: |
${{ runner.os }}-hugo-${{ env.HUGO_VERSION }}-
${{ runner.os }}-hugo-
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Sync content
run: ./.github/scripts/sync-news.sh --mode=auto
- name: Prepare build directories
run: rm -rf public public-worker public-pages
- name: Build site for Cloudflare Workers
env:
HUGO_ENVIRONMENT: production
HUGO_CACHEDIR: ${{ github.workspace }}/.cache/hugo_cache
run: |
hugo \
--gc \
--minify \
--destination public-worker
- name: Build site for GitHub Pages
env:
HUGO_ENVIRONMENT: production
HUGO_CACHEDIR: ${{ github.workspace }}/.cache/hugo_cache
run: |
hugo \
--gc \
--minify \
--destination public-pages \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v4
with:
path: public-pages
- name: Upload Worker asset bundle
uses: actions/upload-artifact@v6
with:
name: site-worker
path: public-worker
if-no-files-found: error
retention-days: 1
deploy-pages:
name: Deploy GitHub Pages
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deploy.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deploy
uses: actions/deploy-pages@v4
deploy-worker:
name: Deploy Cloudflare Worker
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
permissions:
contents: read
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: false
- name: Clean default public directory
run: rm -rf public
- name: Download built site
uses: actions/download-artifact@v7
with:
name: site-worker
path: public
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
command: deploy --config wrangler.jsonc
wranglerVersion: '4.38.0'