[CI] Improve build configuration and dependency management #123
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update website | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
processData: | |
runs-on: ubuntu-latest | |
name: process data file | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22.x' | |
- name: Setup Yarn | |
run: | | |
corepack enable | |
corepack prepare yarn@stable --activate | |
yarn --version | |
- name: get commit info | |
id: commit | |
uses: pr-mpt/actions-commit-hash@v3 | |
with: | |
prefix: 'commit_' | |
- name: Install dependencies | |
run: | | |
yarn install --immutable | |
cd ./src/data | |
yarn install --immutable | |
node processData.js | |
env: | |
COMMITID: ${{ steps.commit.outputs.short }} | |
- name: commit | |
uses: EndBug/[email protected] | |
with: | |
message: "[Bot] Auto process data files" | |
committer_name: "Github Actions Bot - processData" | |
committer_email: "<>" | |
add: . | |
deploy: | |
name: deploy to Tencent COS | |
needs: processData | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22.x' | |
- name: Setup Yarn | |
run: | | |
corepack enable | |
corepack prepare yarn@stable --activate | |
yarn --version | |
- name: Install dependencies & build | |
run: | | |
yarn install --immutable | |
yarn build | |
env: | |
CI: true | |
NODE_ENV: production | |
GENERATE_SOURCEMAP: false | |
- name: Upload COS | |
uses: TencentCloud/cos-action@v1 | |
with: | |
secret_id: ${{ secrets.SECRET_ID }} | |
secret_key: ${{ secrets.SECRET_KEY }} | |
cos_bucket: ${{ secrets.BUCKET }} | |
cos_region: ap-guangzhou | |
local_path: build | |
clean: true | |
- name: Install Python2 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '2.x' | |
architecture: 'x64' | |
- name: refresh CDN | |
run: | | |
pip install tccli | |
tccli cdn PurgeUrlsCache --Area mainland --cli-unfold-argument --Urls https://mir.ug0.ltd | |
env: | |
TENCENTCLOUD_SECRET_ID: ${{ secrets.SECRET_ID }} | |
TENCENTCLOUD_SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
TENCENTCLOUD_REGION: ap-guangzhou |