Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yajuhua committed Apr 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 20a59cf commit c1c60ed
Showing 1 changed file with 16 additions and 79 deletions.
95 changes: 16 additions & 79 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: v2 Test Images
on: workflow_dispatch

jobs:
build-amd64:
build:
permissions: write-all
runs-on: ubuntu-latest
steps:
@@ -23,95 +23,32 @@ jobs:
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- run: cp target/*.jar .

# 设置 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: |
docker build . --file Dockerfile --tag yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
- name: Checkout code
uses: actions/checkout@v2

build-arm64:
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
arch: aarch64

- 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
- run: cp target/*.jar .

# 设置 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
- name: Login to Docker Hub
uses: docker/login-action@v2
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: |
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
- name: Build and push multi-platform image
id: buildx
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: |
yajuhua/podcast2:beta

0 comments on commit c1c60ed

Please sign in to comment.