-
Notifications
You must be signed in to change notification settings - Fork 11
88 lines (79 loc) · 2.53 KB
/
docker-image.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
81
82
83
84
85
86
87
88
name: Docker 构建和发布镜像
on:
push:
branches:
- main
# paths:
# - 'app/**'
workflow_dispatch:
permissions: write-all # 给所有工作写权限
jobs:
jobs_v:
name: 构建版本号和变更信息
runs-on: ubuntu-latest
outputs:
version: ${{ steps.create_version.outputs.NewVersion }} # 版本号
body: ${{ steps.create_body.outputs.Body }} # 版本变更内容
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: 检查是否 "发布"
run: |
latest_commit_message=$(git log -1 --pretty=%B)
if [[ $latest_commit_message == *"发布"* ]]; then
echo "找到发布关键字继续工作流"
else
echo "没有找到发布关键字停止工作流"
exit 1 # 停止工作流程
fi
- name: 递增版本号
id: create_version
uses: duolabmeng6/action-autotag-python@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: 获取更新日志
id: create_body
uses: duolabmeng6/action-Releases-log@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE: .github/releasesText.md
KEYS: bug,改进,优化,新增,删除
- name: 查看版本号和更新日志
run: |
echo ${{ format('version={0}', steps.create_version.outputs.NewVersion ) }}
echo "${{ steps.create_body.outputs.Body }}"
deploy:
name: 发布到docker
needs: [ jobs_v ]
runs-on: ubuntu-latest
env:
version: ${{ needs.jobs_v.outputs.version }}
body: ${{ needs.jobs_v.outputs.Body }}
steps:
- name: 检出代码
uses: actions/checkout@v4
- name: 设置 QEMU
uses: docker/setup-qemu-action@v1
- name: 设置 Docker Buildx
uses: docker/setup-buildx-action@v1.6.0
- name: 登录到 Docker Hub
uses: docker/login-action@v3.0.0
with:
username: duolabmeng
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: 构建并推送 Docker 镜像
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
duolabmeng/pro-api:${{ needs.jobs_v.outputs.version }}
duolabmeng/pro-api:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
provenance: true
sbom: true