Skip to content

build: Update deploy.yml #11

build: Update deploy.yml

build: Update deploy.yml #11

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Deploy to Huawei Cloud Server
on:
push:
branches: [ "master" ]
# 修改文件本身,不触发 actions
# paths-ignore: .github/workflows/deploy.yml
pull_request:
branches: [ "master" ]
# 修改文件本身,不触发 actions
paths-ignore: .github/workflows/deploy.yml
jobs:
build:
# 构建运行在哪个操作系统
runs-on: ubuntu-latest
environment: HuaweiCloud
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
# 构建步骤
steps:
# 拉代码
- name: Checkout repository
uses: actions/checkout@v4
# 安装 Pnpm
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
# 设置 Node.js 环境
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
# 安装依赖
- name: Install dependencies
run: pnpm i
# 打包项目
- name: Build App
run: echo ${{ vars.GREETING }}
#run: pnpm run build && pwd && ls -l ./dist/spa/ && echo ${{ vars.GRETTING }}
# 上传打包后的文件到云服务器
# - name: ssh-scp-ssh-pipelines
# # You may pin to the exact commit or the version.
# # uses: cross-the-world/ssh-scp-ssh-pipelines@78e864b4890087a58248ff39320406971ca88b89
# uses: cross-the-world/[email protected]
# with:
# # ssh remote host
# host: ${{ secrets.IP }}
# # ssh remote port
# port: 58022
# # ssh remote user
# user: ${{ secrets.USER }}
# # content of ssh private key. ex raw content of ~/.ssh/id_rsa
# key: ${{ secrets.SSH_PRIVATE_KEY }}
# # execute pre-commands before scp
# first_ssh: |
# bash ~/projects/homepage/backup.sh
# rm -rf ~/projects/homepage/dist
# # scp from local to remote
# scp: ./dist/* => ~/projects/homepage/dist/
# # execute post-commands after scp
# last_ssh: ls -lh ~/projects/homepage/