Skip to content

Commit 2c5544e

Browse files
committed
✨feat(env): 支持使用环境变量配置谱面地址
1 parent b47ab93 commit 2c5544e

7 files changed

Lines changed: 71 additions & 21 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
if: github.event.repository.owner.id == github.event.sender.id
12+
13+
steps:
14+
- name: Checkout Source
15+
uses: actions/checkout@v2
16+
with:
17+
ref: main
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: '17'
23+
24+
- name: Setup Cache
25+
uses: actions/cache@v3
26+
env:
27+
cache-name: cache-node-modules
28+
with:
29+
# npm cache files are stored in `~/.npm` on Linux/macOS
30+
path: ~/.npm
31+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
32+
restore-keys: |
33+
${{ runner.os }}-build-${{ env.cache-name }}-
34+
${{ runner.os }}-build-
35+
${{ runner.os }}-
36+
37+
- name: Setup Webpack & Install Dependences
38+
run: |
39+
git config --global user.email "64469437+Yuameshi@users.noreply.github.com"
40+
git config --global user.name "Yuameshi"
41+
npm install webpack-cli webpack -g
42+
npm install
43+
44+
- name: Build
45+
run: npm run build
46+
47+
- name: Deploy
48+
uses: peaceiris/actions-gh-pages@v3
49+
with:
50+
github_token: ${{ secrets.GITHUB_TOKEN }}
51+
publish_dir: ./dist
52+
53+
- name: Trigger APP CI Build
54+
run: |
55+
curl 'https://api.github.com/repos/Yuameshi/PhiCommunityAPP/dispatches' --request POST \
56+
-H 'Accept: application/vnd.github.v3+json' \
57+
-H 'Content-Type: application/json' \
58+
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
59+
--data-raw '{"event_type": "CI Build triggered by Repo:PhiCommunity"}'

config/webpack.common.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
44
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
55
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
66
const { GitRevisionPlugin } = require('git-revision-webpack-plugin');
7+
require('dotenv').config();
78

89
const path = require('path');
910

@@ -98,6 +99,9 @@ module.exports = {
9899
gitRevisionPlugin,
99100
new webpack.DefinePlugin({
100101
$VERSION: JSON.stringify(gitRevisionPlugin.version()),
102+
'process.env.CHARTS_SOURCE': JSON.stringify(process.env.CHARTS_SOURCE),
103+
'process.env.CHARTS_SOURCE_CF': JSON.stringify(process.env.CHARTS_SOURCE_CF),
104+
'process.env.CHARTS_SOURCE_VERCEL': JSON.stringify(process.env.CHARTS_SOURCE_VERCEL),
101105
}),
102106
new MiniCssExtractPlugin({
103107
filename: 'css/[name].[contenthash].css',

jsconfig.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"clean-webpack-plugin": "^4.0.0",
2525
"copy-webpack-plugin": "^10.2.4",
2626
"css-loader": "^6.6.0",
27+
"dotenv": "^17.2.1",
2728
"eslint": "^8.13.0",
2829
"file-loader": "^6.2.0",
2930
"git-revision-webpack-plugin": "^5.0.0",
@@ -40,7 +41,6 @@
4041
},
4142
"dependencies": {
4243
"dom-element-factory": "^1.5.0",
43-
"dotenv": "^17.2.1",
4444
"oggmented": "^1.0.1",
4545
"stackblur-canvas": "^2.5.0",
4646
"workbox-core": "^6.5.1",

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h2>变更记录(仅显示最近30次)</h2>
4141
>点击此处查看所有提交</a
4242
>
4343
<img
44-
src="https://repobeats.axiom.co/api/embed/8d2203c93b7bb141dff3abc99bd0d0b3a58d85f9.svg"
44+
src="https://repobeats.axiom.co/api/embed/125bc98186c7e24a2a628ada266d29d8e9c1e7b1.svg"
4545
alt="变更情况总览"
4646
/>
4747
<br /><br />

src/utils/chartSource.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const chartSource = isCloudflarePages()
2-
? 'https://cf.charts.phicm.focalors.ltd'
2+
? process.env.CHARTS_SOURCE_CF
33
: isVercel()
4-
? 'https://vercel.charts.phicm.focalors.ltd'
5-
: 'https://charts.phicm.focalors.ltd';
4+
? process.env.CHARTS_SOURCE_VERCEL
5+
: process.env.CHARTS_SOURCE
66

77
function isCloudflarePages() {
88
return window.location.hostname.includes('cf');

0 commit comments

Comments
 (0)