build: deploy to laf #1
Workflow file for this run
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: Build | |
on: | |
push: | |
branches: | |
- demo | |
env: | |
BUCKET_NAME: ${{ secrets.DOC_BUCKET_NAME }} | |
LAF_APPID: ${{ secrets.LAF_APPID }} | |
LAF_PAT: ${{ secrets.LAF_PAT }} | |
API_URL: 'https://ukw0y1.laf.run' | |
WEB_PATH: . | |
DIST_PATH: 'dist/build/h5' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
# 安装项目依赖 | |
- name: Install Dependencies | |
working-directory: ${{ env.WEB_PATH }} | |
run: npm install | |
# 编译项目 | |
- name: Build | |
working-directory: ${{ env.WEB_PATH }} | |
run: npm run build | |
# 安装 laf-cli | |
- name: Install Laf-CLI | |
run: npm i laf-cli -g | |
# 登录 laf api | |
- name: Login laf-cli | |
working-directory: ${{ env.WEB_PATH }} | |
run: | | |
laf user add ${{ env.LAF_APPID }} -r ${{ env.API_URL }} | |
laf user switch ${{ env.LAF_APPID }} | |
laf login $LAF_PAT | |
# 初始化 Laf 应用然后将编译好的代码推送到云存储 | |
- name: Init appid and push | |
working-directory: ${{ env.WEB_PATH }} | |
env: | |
LAF_APPID: ${{ env.LAF_APPID }} | |
run: | | |
laf app init ${{ env.LAF_APPID }} | |
laf storage push -f ${{ env.BUCKET_NAME }} ${{ env.DIST_PATH }}/ |