添加workflow

This commit is contained in:
Xwite 2023-04-07 21:41:29 +08:00
parent 57e2c3a418
commit a0cc1749dd
8 changed files with 51 additions and 138 deletions

48
.github/workflows/web.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Build Web
on:
push:
branches:
- master
paths:
- '**/modules/web/**'
workflow_dispatch:
env:
UPSTREAM_REPOSITORY: gedoor/legado
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build
run: |
cd $GITHUB_WORKSPACE/modules/web
pnpm i
pnpm build
rm -rf legado/app/src/main/assets/web/source
rm -rf legado/app/src/main/assets/web/bookshelf
rm -rf legado/app/src/main/assets/web/vue
mkdir legado/app/src/main/assets/web/vue
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
if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
uses: stefanzweifel/git-auto-commit-action@v4.16.0
with:
commit_message: Bump web v${{ env.APP_VER}}
file_pattern: app/src/main/assets/web/vue/

View File

@ -1,5 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/web.iml" filepath="$PROJECT_DIR$/.idea/web.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../../../.." vcs="Git" />
</component>
</project>

View File

@ -44,11 +44,11 @@
<!-- <p>A responsive site template designed by HTML5 UP<br />
and released under the Creative Commons.</p> -->
<ul class="actions">
<li><a href="bookshelf/index.html" class="button next scrolly" target="_blank">书架</a>
<li><a href="vue/index.html" class="button next scrolly" target="_blank">书架</a>
</li>
</ul>
<ul class="actions">
<li><a href="source/index.html#/bookSource" class="button next scrolly"
<li><a href="vue/index.html#/bookSource" class="button next scrolly"
target="_blank">书源</a></li>
</ul>
<ul class="actions">
@ -56,7 +56,7 @@
</li>
</ul>
<ul class="actions">
<li><a href="source/index.html#/rssSource" class="button next scrolly"
<li><a href="vue/index.html#/rssSource" class="button next scrolly"
target="_blank">订阅源</a></li>
</ul>
</div>

View File

@ -1,10 +0,0 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "daily"

View File

@ -1,66 +0,0 @@
name: Build
on:
push:
branches:
- main
workflow_dispatch:
env:
UPSTREAM_REPOSITORY: gedoor/legado_web_source_editor
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Project
run: |
npm install
- name: Format code
if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
run: |
npm run-script lint
- name: push changes
if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
uses: stefanzweifel/git-auto-commit-action@v4.16.0
with:
commit_message: 'style: format code'
file_pattern: src
- name: Build
run: |
npm run-script build
- name: Set Env
if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
shell: bash
run: |
version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
echo "APP_VER=$version" >> $GITHUB_ENV
- name: Push changes to legado
continue-on-error: true
if: ${{ github.repository == env.UPSTREAM_REPOSITORY }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git clone "https://gedoor:${{ secrets.ACTIONS_TOKEN }}@github.com/gedoor/legado" --depth 1
rm -rf legado/app/src/main/assets/web/source/*
mv -f $GITHUB_WORKSPACE/dist/* legado/app/src/main/assets/web/source/
cd legado
git add -A
git commit -m "web source editor: ${{ env.APP_VER }}"
git push

View File

@ -1,40 +0,0 @@
name: Release
on: [workflow_dispatch]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set Env
shell: bash
run: |
version="v$(date -d "8 hour" -u +3.%y.%m%d%H)"
echo "VERSION=$version" >> $GITHUB_ENV
- name: Build
run: |
npm install
npm run-script build
zip -q -r ${{github.ref_name}}_${{env.VERSION}}.zip ./dist
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.VERSION }}
tag_name: ${{ env.VERSION }}
draft: false
prerelease: false
files: ${{ github.workspace }}/*.zip