-
Notifications
You must be signed in to change notification settings - Fork 67
87 lines (78 loc) · 2.65 KB
/
docker-image.yml
File metadata and controls
87 lines (78 loc) · 2.65 KB
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
name: Publish Docker Image
on:
push:
branches:
- main
tags:
- '*'
paths:
- 'api-service/**'
- '.github/workflows/docker-image.yml'
workflow_dispatch:
inputs:
name:
description: 'Person to greet'
required: true
default: 'Mona the Octocat'
home:
description: 'location'
required: false
default: 'The Octoverse'
env:
APP_NAME: wechat-decrypt-api
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_USERNAME }}/wechat-decrypt-api
jobs:
main:
runs-on: ubuntu-latest
steps:
# git checkout 代码
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # 获取完整的 git 历史,以便 git describe 工作
# 设置 QEMU, 后面 docker buildx 依赖此
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV
# 构建 Docker 并推送到 Docker hub
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./api-service
file: ./api-service/Dockerfile
push: true
# 生成多平台镜像
platforms: |
linux/amd64
linux/arm64
# docker build arg, 注入 APP_NAME/APP_VERSION
build-args: |
APP_NAME=${{ env.APP_NAME }}
APP_VERSION=${{ env.APP_VERSION }}
# 生成两个 docker tag: ${APP_VERSION} 和 latest
tags: |
${{ env.DOCKERHUB_REPO }}:latest
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
# 自动更新 Docker Hub 描述(从 README.md 同步到 overview)
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: ${{ env.DOCKERHUB_REPO }}
readme-filepath: ./README.md
short-description: "微信视频号解密工具 API 服务 - 基于 Isaac64 PRNG 算法的视频解密服务"