This commit is contained in:
35
.gitea/workflows/npm-build-on-push.yaml
Normal file
35
.gitea/workflows/npm-build-on-push.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
## 工作流名称
|
||||
name: huaian-screen
|
||||
|
||||
## 工作流触发时机
|
||||
on: [ push ]
|
||||
|
||||
env:
|
||||
VERSION: $(echo '${{ github.event.head_commit.message }}' | sed -n 's/.*release(\([^)]*\)).*/\1/p')
|
||||
DOMAIN_NAME: ts-official.tmp.tieshengkeji.cn
|
||||
FLODER_NAME: huaian
|
||||
|
||||
jobs:
|
||||
## 任务名称
|
||||
build:
|
||||
## 任务执行的服务器
|
||||
runs-on: tiesheng-local
|
||||
if: ${{ startsWith(github.event.head_commit.message,'release') }}
|
||||
|
||||
## 任务步骤
|
||||
steps:
|
||||
## 检出代码(固定配置)
|
||||
- name: Check out repository code
|
||||
uses: https://git.tieshengkeji.com/actions/checkout@v4
|
||||
|
||||
## 下载前端依赖
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
## 前端项目打包并发送到本地
|
||||
- name: Build Frontend
|
||||
run: |
|
||||
npm run build
|
||||
rm -rf /usr/local/nginx/html/${{env.DOMAIN_NAME}}/static/${{env.FLODER_NAME}}
|
||||
mv dist "${{env.FLODER_NAME}}"
|
||||
mv ${{env.FLODER_NAME}} /usr/local/nginx/html/${{env.DOMAIN_NAME}}/static
|
||||
83
.gitea/workflows/npm-build-on-tag.yaml
Normal file
83
.gitea/workflows/npm-build-on-tag.yaml
Normal file
@ -0,0 +1,83 @@
|
||||
## 工作流名称
|
||||
name: yxr-manager
|
||||
|
||||
## 工作流触发时机
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*' # 匹配所有标签
|
||||
|
||||
jobs:
|
||||
## 任务名称
|
||||
build:
|
||||
## 任务执行的服务器
|
||||
runs-on: tiesheng-local
|
||||
|
||||
## 任务步骤
|
||||
steps:
|
||||
## 检出代码(固定配置)
|
||||
- name: Check out repository code
|
||||
uses: https://git.tieshengkeji.com/actions/checkout@v4
|
||||
|
||||
## 下载前端依赖
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
## 获取当前仓库名称和标签名称
|
||||
- name: Get repository name and tag name
|
||||
id: repo-info
|
||||
run: |
|
||||
echo "::set-output name=repo_name::$(basename ${GITHUB_REPOSITORY})"
|
||||
echo "::set-output name=tag_name::${GITHUB_REF#refs/tags/}"
|
||||
|
||||
## 检查本地该项目文件夹是否存在
|
||||
- name: Check if local directory exists
|
||||
id: check-local-directory
|
||||
run: |
|
||||
if [ -d "/usr/local/nginx/html/dist.tmp.tieshengkeji.cn/${{ steps.repo-info.outputs.repo_name }}" ]; then
|
||||
echo "Directory exists, skipping creation."
|
||||
echo "::set-output name=directory_exists::true"
|
||||
else
|
||||
echo "Directory does not exist, will create."
|
||||
echo "::set-output name=directory_exists::false"
|
||||
fi
|
||||
|
||||
## 不存在则创建项目文件夹
|
||||
- name: Create Project Directory
|
||||
if: ${{ steps.check-local-directory.outputs.directory_exists != 'true' }}
|
||||
run: |
|
||||
mkdir /usr/local/nginx/html/dist.tmp.tieshengkeji.cn/${{ steps.repo-info.outputs.repo_name }}
|
||||
|
||||
## 前端项目打包并发送到本地
|
||||
- name: Build Frontend
|
||||
run: |
|
||||
npm run build
|
||||
mv dist "${{ steps.repo-info.outputs.tag_name }}"
|
||||
zip -r ${{ steps.repo-info.outputs.repo_name }}${{ steps.repo-info.outputs.tag_name }}.zip ${{ steps.repo-info.outputs.tag_name }}
|
||||
mv ${{ steps.repo-info.outputs.repo_name }}${{ steps.repo-info.outputs.tag_name }}.zip /usr/local/nginx/html/dist.tmp.tieshengkeji.cn/${{ steps.repo-info.outputs.repo_name }}
|
||||
|
||||
##获取最后一条提交消息
|
||||
- name: Get commit title
|
||||
id: get_commit_title
|
||||
run: |
|
||||
COMMIT_TITLE=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
|
||||
echo "::set-output name=commit_title::$COMMIT_TITLE"
|
||||
|
||||
## 发送钉钉消息
|
||||
- name: Send DingDing notification using curl
|
||||
run: |
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"msgtype": "text",
|
||||
"at": {
|
||||
"atMobiles":[
|
||||
"18175194630",
|
||||
],
|
||||
"isAtAll": false
|
||||
},
|
||||
"text": {
|
||||
"content": "@18175194630 项目【${{ steps.repo-info.outputs.repo_name }}】打包完成,版本号${{ steps.repo-info.outputs.tag_name }}。\n 操作人:${{ github.actor }} \n 内容:${{ steps.get_commit_title.outputs.commit_title }} \n https://dist.tmp.tieshengkeji.cn/${{ steps.repo-info.outputs.repo_name }}/${{ steps.repo-info.outputs.repo_name }}${{ steps.repo-info.outputs.tag_name }}.zip"
|
||||
},
|
||||
}' \
|
||||
'https://oapi.dingtalk.com/robot/send?access_token=${{vars.DINGTALK_ACCESS_TOKEN}}'
|
||||
Reference in New Issue
Block a user