发布 加入一些头信息 #64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v3 | |
- name: 设置 Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- 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=gha | |
cache-to: type=gha,mode=max | |
provenance: true | |
sbom: true | |