Skip to content

Commit

Permalink
chore: add competition side build
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamerblue committed May 9, 2024
1 parent 7cc9e9a commit bdee5d8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 6 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-upload:
build-and-upload-release:
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
Expand Down Expand Up @@ -51,3 +51,47 @@ jobs:
run: npm ci --registry=https://registry.npmjs.org

- run: npm run build:cdn
build-and-upload-release-cs:
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_REGION: ${{ secrets.COS_REGION }}
COS_TARGET_BASE: ${{ secrets.COS_TARGET_BASE }}
CDN_URL: ${{ secrets.CDN_URL }}
MEDIA_URL: ${{ secrets.MEDIA_URL }}
DATA_USING_GIT: 0
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-cs-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-cs-build-${{ env.cache-name }}-
${{ runner.os }}-cs-build-
${{ runner.os }}-cs-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list

- name: Install Dependencies
run: npm ci --registry=https://registry.npmjs.org

- run: npm run build:competition-side:cdn
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yarn.lock
/onlinejudge3_exp
/onlinejudge3_barkalways
/onlinejudge3_test
/onlinejudge3_cs
5 changes: 5 additions & 0 deletions .umirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const buildConfig = {
publicPath: `${publicPathPrefix}/onlinejudge3/`,
outputPath: './onlinejudge3',
},
release_competition_side: {
base: '/onlinejudge3_cs/',
publicPath: `${publicPathPrefix}/onlinejudge3_cs/`,
outputPath: './onlinejudge3_cs',
},
// exp: {
// base: '/onlinejudge3_exp/',
// publicPath: `${publicPathPrefix}/onlinejudge3_exp/`,
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "onlinejudge3-fe",
"version": "3.6.1",
"version": "3.6.2",
"description": "",
"scripts": {
"dev": "gulp dev",
"dev:competition-side": "cross-env COMPETITION_SIDE=1 gulp dev",
"start": "cross-env BROWSER=none umi dev",
"dup-less": "gulp dup-less",
"build": "umi build",
"build:cdn": "umi build && node tasks/upload-cdn.js",
"build:competition-side": "cross-env COMPETITION_SIDE=1 umi build",
"build:cdn": "npm run build && node tasks/upload-cdn.js",
"build:competition-side": "cross-env COMPETITION_SIDE=1 OJ3_BUILD4=release_competition_side umi build",
"build:competition-side:cdn": "npm run build:competition-side && cross-env COMPETITION_SIDE=1 node tasks/upload-cdn.js onlinejudge3_cs",
"build-analyze": "cross-env ANALYZE=1 umi build",
"line-count": "cloc src/ --exclude-dir=.umi,.umi-production --fullpath --not-match-f='/(styles/dark_antd|styles/dark_antd_duplicated4auto|assets|configs/codes)/'",
"pull-submodule": "git submodule foreach git pull origin master",
Expand Down
7 changes: 5 additions & 2 deletions tasks/upload-cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ const cos = new COS({
const Bucket = process.env.COS_BUCKET;
const Region = process.env.COS_REGION;


const publicDir = process.argv[2] || 'onlinejudge3';
console.log('Using public dir:', publicDir);
const cosTargetBase = process.env.COS_TARGET_BASE || ''; // should end with /
const localFolder = './onlinejudge3/';
const remotePrefix = `${cosTargetBase}onlinejudge3/`;
const localFolder = `./${publicDir}/`;
const remotePrefix = `${cosTargetBase}${publicDir}/`;

const fastListFolder = function(options, callback) {
const pathJoin = function(dir, name, isDir) {
Expand Down

0 comments on commit bdee5d8

Please sign in to comment.