-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (80 loc) · 2.68 KB
/
dispatch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: dispatch
on:
workflow_dispatch:
inputs:
run_type:
description: '运行方式'
required: true
default: '构建快照'
type: choice
options:
- 构建快照
- 批准PR
- 发布预览版
PR_ID:
description: 需要批准的PR ID
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 获取信息
id: get_info
run: |
echo "repository_name=${GITHUB_REPOSITORY/${{ github.repository_owner }}\//}" >> $GITHUB_OUTPUT
echo 本次运行方式: ${{ inputs.run_type }}
if [ "${{ inputs.run_type }}" == "构建快照" ]; then
echo "run_type_en=SNAPSHOT" >> $GITHUB_OUTPUT
elif [ "${{ inputs.run_type }}" == "批准PR" ]; then
echo "run_type_en=PR Approve" >> $GITHUB_OUTPUT
else
echo "run_type_en=Preview" >> $GITHUB_OUTPUT
fi
- name: 拉取代码
uses: actions/checkout@v4.1.1
# 必须先执行一次checkout才能执行这个
- name: 拉取代码(批准PR专用)
if: inputs.run_type == '批准PR'
run: |
ls -la
gh pr checkout ${{ inputs.PR_ID }}
ls -la
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 安装java8
uses: actions/setup-java@v4.2.1
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: 构建
run: |
mvn -B package --file pom.xml
mkdir staging && cp target/*.jar staging
- name: 批准PR
if: inputs.run_type == '批准PR'
uses: hmarr/auto-approve-action@v4.0.0
with:
pull-request-number: ${{ inputs.PR_ID }}
review-message: |
编译已通过,批准通过
如果有新的提交则取消本次批准
- name: 收集构建文件
uses: actions/upload-artifact@v1
with:
name: ${{ steps.get_info.outputs.repository_name }}-${{ steps.get_info.outputs.run_type_en }}-Build-${{ github.run_number}}
path: staging
- name: 发布预览版
if: inputs.run_type == '发布预览版'
uses: ncipollo/release-action@v1.14.0
with:
tag: ${{ steps.get_info.outputs.run_type_en }}-Build-${{ github.run_number}}
name: ${{ steps.get_info.outputs.run_type_en }}-Build-${{ github.run_number}}
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
commit: ${{ steps.get_info.outputs.run_type_en }}-Build-${{ github.run_number}}
body: |
此版本为预览版
相关更新关系日志请等待正式版发布后方可查看
你也可以查看commit记录来获取更新日志
artifacts: ./staging/*.jar