Files
other-web/.githun/workflows/main.yml
2024-11-30 23:41:42 +08:00

60 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Deploy
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 运行环境,告诉它运行在什么环境
steps: # 步骤
# 第一步下载源码CI/CD拉取代码到自己的本地
- name: Checkout
uses: actions/checkout@main
# 第二步:打包构建
- name: Build
uses: actions/setup-node@main
# - run: npm install # 安装第三方包
# - run: npm run build # 打包
- run: tar -zcvf release.tgz .
# 把当前源代码目录所有文件打包压缩为release.tgz
# 第三步:发布 Release
- name: Create Release # 创建Release可以在仓库看到一个个版本
id: create_release
uses: actions/create-release@main
# env:
# GITHUB_TOKEN: ${{ secrets.TOKEN }} # 之前GitHub添加的Token
with:
tag_name: ubdata
release_name: Release ubdata
draft: false # 是否是草稿
prerelease: false # 是否是预发布
# 第四步:上传构建结果到 Release把打包的tgz上传到Release
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@main
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # 上传地址通过创建Release获取到的
asset_path: ./release.tgz # 要上传文件
asset_name: release.tgz # 上传后的文件名
asset_content_type: application/x-tgz
# 第五步:部署到服务器
- name: Deploy
uses: appleboy/ssh-action@main # 使用ssh链接服务器
with:
host: 10.147.17.161
username: root
password: Hxl110119
port: 22
script: | # 执行命令运行到服务器cd要确保服务器有这个目录 wget下载上一步的release到服务器 tar解压 安装依赖;启动服务
cd /www/1panel/apps/openresty/openresty/www/sites/other/index
wget http://10.147.17.160:3000/he_and_smallyue/other-web/releases/latest/download/release.tgz -O release.tgz
tar zxvf release.tgz