-
Notifications
You must be signed in to change notification settings - Fork 8
115 lines (103 loc) · 4.17 KB
/
test.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: v2 Test Images
on: workflow_dispatch
jobs:
build-jar:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
# 获取 Maven 项目版本
- name: Get Maven Project Version
id: get_version
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
echo $PWD
- run: cp target/*.jar .
build-amd64:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
# 构建 amd64 Docker镜像
- name: Build the amd64 Docker image
run: |
echo $PWD
docker build . --file Dockerfile --tag yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
build-arm64:
permissions: write-all
runs-on: ubuntu-latest
needs: build-jar
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
arch: aarch64
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}
# 构建 amd64 Docker 并推送到 Docker hub
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
push-docker-hub:
permissions: write-all
runs-on: ubuntu-latest
needs: [build-arm64,build-amd64]
steps:
- name: pull amd4 and arm64 docker images
run: |
docker pull yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
docker pull yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
- name: create manifest
run: |
docker manifest create yajuhua/podcast2:beta-$(date +%Y-%m-%d) yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d) yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
- name: push manifest
run: |
docker manifest push yajuhua/podcast2:beta