mirror of
https://github.com/RayLabsHQ/gitea-mirror.git
synced 2025-12-14 07:26:44 +03:00
93 lines
2.6 KiB
YAML
93 lines
2.6 KiB
YAML
name: Build and Push Docker Images (Multi-Arch)
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
pull_request:
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
IMAGE: ${{ github.repository }}
|
|
|
|
jobs:
|
|
# Build platform-specific images in parallel
|
|
build:
|
|
name: Build ${{ matrix.platform }}
|
|
runs-on: ${{ matrix.runner }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- platform: linux/amd64
|
|
runner: ubuntu-latest
|
|
platform-suffix: amd64
|
|
- platform: linux/arm64
|
|
runner: macos-latest
|
|
platform-suffix: arm64
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
services:
|
|
redis:
|
|
image: redis:7-alpine
|
|
ports: ['6379:6379']
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@v3
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: ${{ matrix.platform }}
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ matrix.platform-suffix }}-${{ github.sha }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
# Create and push the multi-platform manifest
|
|
manifest:
|
|
name: Create and Push Manifest
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
if: github.event_name != 'pull_request'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Create and push manifest
|
|
run: |
|
|
# Create and push the manifest with both architectures
|
|
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE }}:amd64-${{ github.sha }} \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE }}:arm64-${{ github.sha }}
|
|
|
|
docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE }}:amd64-${{ github.sha }} \
|
|
${{ env.REGISTRY }}/${{ env.IMAGE }}:arm64-${{ github.sha }}
|
|
|
|
# Push the manifests
|
|
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
|
|
docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }} |