Skip to content

Build and Push Multi-Arch Docker Image #226

Build and Push Multi-Arch Docker Image

Build and Push Multi-Arch Docker Image #226

Workflow file for this run

name: Build and Push Multi-Arch Docker Image
on:
push:
branches: [ "main" ]
schedule:
- cron: '0 18 * * 1,3,5'
workflow_dispatch:
env:
IMAGE_NAME: "bypanel/nginx"
DOCKERFILE_PATH: "Dockerfile.latest"
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# 硬编码稳定版配置
- version: "1.28.3"
tags: |
bypanel/nginx:1.28.3
bypanel/nginx:stable
bypanel/nginx:latest
# 硬编码主线版配置
- version: "1.29.7"
tags: |
bypanel/nginx:1.29.7
bypanel/nginx:mainline
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set build date
run: |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
with:
driver-opts: |
network=host
- name: Build and push multi-arch image
uses: docker/build-push-action@v7
with:
context: .
file: ${{ env.DOCKERFILE_PATH }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ matrix.tags }}
build-args: |
DISTRO=alpine
DISTRO_VER=latest
VER_NGINX=${{ matrix.version }}
BUILD_DATE=${{ env.BUILD_DATE }}