2023-04-07 21:41:29 +08:00
|
|
|
name: Build Web
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
paths:
|
|
|
|
- '**/modules/web/**'
|
2023-04-16 08:59:15 +08:00
|
|
|
pull_request:
|
|
|
|
paths:
|
|
|
|
- '**/modules/web/**'
|
2023-04-07 21:41:29 +08:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
env:
|
|
|
|
UPSTREAM_REPOSITORY: gedoor/legado
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2023-04-08 20:01:12 +08:00
|
|
|
- name: Checkout
|
2023-04-07 21:41:29 +08:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2023-04-08 20:01:12 +08:00
|
|
|
- name: Install Node.js
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
|
|
|
|
- uses: pnpm/action-setup@v2
|
|
|
|
name: Install pnpm
|
|
|
|
id: pnpm-install
|
|
|
|
with:
|
|
|
|
version: 8
|
|
|
|
run_install: false
|
|
|
|
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
id: pnpm-cache
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-04-07 21:41:29 +08:00
|
|
|
- uses: actions/cache@v3
|
2023-04-08 20:01:12 +08:00
|
|
|
name: Setup pnpm cache
|
2023-04-07 21:41:29 +08:00
|
|
|
with:
|
2023-04-08 20:01:12 +08:00
|
|
|
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/web/package.json') }}
|
2023-04-07 21:41:29 +08:00
|
|
|
restore-keys: |
|
2023-04-08 20:01:12 +08:00
|
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
|
|
|
|
- name: Build and move files
|
2023-04-07 21:41:29 +08:00
|
|
|
run: |
|
2023-04-07 21:47:12 +08:00
|
|
|
rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/source
|
|
|
|
rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/bookshelf
|
|
|
|
rm -rf $GITHUB_WORKSPACE/app/src/main/assets/web/vue
|
|
|
|
mkdir $GITHUB_WORKSPACE/app/src/main/assets/web/vue
|
2023-04-07 21:41:29 +08:00
|
|
|
cd $GITHUB_WORKSPACE/modules/web
|
2023-04-08 20:05:45 +08:00
|
|
|
pnpm i
|
2023-04-08 20:01:12 +08:00
|
|
|
pnpm build
|
2023-04-07 21:41:29 +08:00
|
|
|
mv -f ./dist/* $GITHUB_WORKSPACE/app/src/main/assets/web/vue/
|
|
|
|
version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
|
|
|
|
echo "APP_VER=$version" >> $GITHUB_ENV
|
|
|
|
|
|
|
|
- name: push changes
|
2023-04-16 08:59:15 +08:00
|
|
|
if: ${{ github.event_name != 'pull_request' && github.repository == env.UPSTREAM_REPOSITORY }}
|
2023-04-07 21:41:29 +08:00
|
|
|
uses: stefanzweifel/git-auto-commit-action@v4.16.0
|
|
|
|
with:
|
2023-04-08 08:52:19 +08:00
|
|
|
commit_message: Bump web ${{ env.APP_VER}}
|
2023-04-07 21:41:29 +08:00
|
|
|
file_pattern: app/src/main/assets/web/vue/
|
|
|
|
|