mirror of
https://github.com/jiangrui1994/CloudSaver.git
synced 2026-01-10 15:18:46 +08:00
build:完善构建流程
This commit is contained in:
17
.github/workflows/docker-build-test.yml
vendored
17
.github/workflows/docker-build-test.yml
vendored
@@ -1,17 +1,15 @@
|
||||
name: Build and Push Multi-Arch Docker Image for Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch: # 添加手动触发
|
||||
workflow_dispatch: # 添加手动触发
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write # 必须授权以推送镜像
|
||||
packages: write # 必须授权以推送镜像
|
||||
env:
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
@@ -28,6 +26,12 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 登录到 Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: 设置 QEMU 支持多架构
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
@@ -38,7 +42,8 @@ jobs:
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64 # 指定架构:x86_64 和 ARM64
|
||||
platforms: linux/amd64,linux/arm64 # 指定架构:x86_64 和 ARM64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ env.LOWER_NAME }}:test
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.LOWER_NAME }}:test
|
||||
|
||||
23
.github/workflows/docker-image.yml
vendored
23
.github/workflows/docker-image.yml
vendored
@@ -1,24 +1,27 @@
|
||||
name: Docker Image CI/CD
|
||||
on:
|
||||
push:
|
||||
tags: [ "v*.*.*" ] # 支持标签触发(如 v1.0.0)
|
||||
workflow_dispatch: # 添加手动触发
|
||||
tags: ["v*.*.*"] # 支持标签触发(如 v1.0.0)
|
||||
workflow_dispatch: # 添加手动触发
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write # 必须授权以推送镜像
|
||||
packages: write # 必须授权以推送镜像
|
||||
env:
|
||||
REPO_NAME: ${{ github.repository }}
|
||||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 设置小写镜像名称
|
||||
- name: 设置小写镜像名称和版本
|
||||
run: |
|
||||
LOWER_NAME=$(echo "$REPO_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
echo "LOWER_NAME=$LOWER_NAME" >> $GITHUB_ENV
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
|
||||
- name: 登录到 GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
@@ -27,6 +30,12 @@ jobs:
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: 登录到 Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: 设置 QEMU 支持多架构
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
@@ -37,8 +46,10 @@ jobs:
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64 # 指定架构:x86_64 和 ARM64
|
||||
platforms: linux/amd64,linux/arm64 # 指定架构:x86_64 和 ARM64
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ env.LOWER_NAME }}:latest
|
||||
ghcr.io/${{ env.LOWER_NAME }}:${{ github.sha }}
|
||||
ghcr.io/${{ env.LOWER_NAME }}:${{ env.VERSION }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.LOWER_NAME }}:latest
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.LOWER_NAME }}:${{ env.VERSION }}
|
||||
|
||||
Reference in New Issue
Block a user