-
Notifications
You must be signed in to change notification settings - Fork 0
176 lines (165 loc) · 5.26 KB
/
Copy pathbuild.yml
File metadata and controls
176 lines (165 loc) · 5.26 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
NODE_VERSION: 24.14.0
NPM_VERSION: 11.9.0
WEB_DEPLOY_REPOSITORY: zijian-z/rss-reader-page
WEB_DEPLOY_BRANCH: main
jobs:
web:
name: Web
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure npm
shell: bash
run: |
npm config set cache "$RUNNER_TEMP/npm-cache" --global
npm install -g npm@${{ env.NPM_VERSION }}
npm config set cache "$RUNNER_TEMP/npm-cache" --global
node --version
npm --version
npm config get cache
- name: Install dependencies
run: npm ci --no-audit --no-fund --prefer-online
- name: Print npm debug logs
if: failure()
shell: bash
run: |
shopt -s nullglob
logs=("$RUNNER_TEMP"/npm-cache/_logs/*.log)
if [ ${#logs[@]} -eq 0 ]; then
echo "No npm debug logs found in $RUNNER_TEMP/npm-cache/_logs"
exit 0
fi
for log in "${logs[@]}"; do
echo "::group::$(basename "$log")"
sed -n '1,320p' "$log"
echo "::endgroup::"
done
- name: Upload npm debug logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: npm-debug-logs-web
path: ${{ runner.temp }}/npm-cache/_logs/*.log
if-no-files-found: ignore
- run: npm run build
- uses: actions/upload-artifact@v4
with:
name: rss-reader-web
path: dist
deploy-web:
name: Deploy Web
runs-on: ubuntu-latest
needs: web
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
steps:
- uses: actions/download-artifact@v4
with:
name: rss-reader-web
path: dist
- name: Push dist to page repository
shell: bash
env:
DEPLOY_TOKEN: ${{ secrets.RSS_READER_PAGE_TOKEN }}
run: |
set -euo pipefail
if [ -z "${DEPLOY_TOKEN}" ]; then
echo "RSS_READER_PAGE_TOKEN is not set; skipping web deployment."
exit 0
fi
repo_url="https://x-access-token:${DEPLOY_TOKEN}@github.com/${WEB_DEPLOY_REPOSITORY}.git"
workdir="${RUNNER_TEMP}/rss-reader-page"
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git clone "$repo_url" "$workdir"
cd "$workdir"
git checkout -B "$WEB_DEPLOY_BRANCH"
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp -R "${GITHUB_WORKSPACE}/dist/." .
touch .nojekyll
git add -A
if git diff --cached --quiet; then
echo "No web changes to deploy."
exit 0
fi
git commit -m "Deploy web build ${GITHUB_SHA::7}"
git push origin "HEAD:${WEB_DEPLOY_BRANCH}"
desktop:
name: Desktop ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure npm
shell: bash
run: |
npm config set cache "$RUNNER_TEMP/npm-cache" --global
npm install -g npm@${{ env.NPM_VERSION }}
npm config set cache "$RUNNER_TEMP/npm-cache" --global
node --version
npm --version
npm config get cache
- name: Install dependencies
run: npm ci --no-audit --no-fund --prefer-online
- name: Print npm debug logs
if: failure()
shell: bash
run: |
shopt -s nullglob
logs=("$RUNNER_TEMP"/npm-cache/_logs/*.log)
if [ ${#logs[@]} -eq 0 ]; then
echo "No npm debug logs found in $RUNNER_TEMP/npm-cache/_logs"
exit 0
fi
for log in "${logs[@]}"; do
echo "::group::$(basename "$log")"
sed -n '1,320p' "$log"
echo "::endgroup::"
done
- name: Upload npm debug logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: npm-debug-logs-desktop-${{ matrix.os }}
path: ${{ runner.temp }}/npm-cache/_logs/*.log
if-no-files-found: ignore
- name: Build desktop app
shell: bash
env:
CSC_IDENTITY_AUTO_DISCOVERY: false
run: |
set -o pipefail
npm run app:dist 2>&1 | tee desktop-build.log
- name: Upload desktop build log
if: failure()
uses: actions/upload-artifact@v4
with:
name: desktop-build-log-${{ matrix.os }}
path: desktop-build.log
if-no-files-found: ignore
- uses: actions/upload-artifact@v4
with:
name: rss-reader-desktop-${{ matrix.os }}
path: |
release/*.dmg
release/*.zip
release/*.exe
release/*.AppImage
release/*.deb
if-no-files-found: error