68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
name: Docker Images CI
|
|
on:
|
|
push:
|
|
branches: main
|
|
|
|
jobs:
|
|
build-platform:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
platform: [linux/amd64, linux/arm/v7, linux/arm64/v8]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v4
|
|
id: cache
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build and push platform-specific image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
tags: albertoxamin/bang:${{ matrix.platform | replace('/', '-') }}
|
|
cache-from: type=registry,ref=albertoxamin/bang:${{ matrix.platform }}
|
|
cache-to: type=inline
|
|
|
|
create-manifest:
|
|
runs-on: ubuntu-latest
|
|
needs: build-platform
|
|
steps:
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Create and push multi-arch manifest
|
|
run: |
|
|
docker buildx imagetools create \
|
|
--tag albertoxamin/bang:latest \
|
|
albertoxamin/bang:linux-amd64 \
|
|
albertoxamin/bang:linux-arm-v7 \
|
|
albertoxamin/bang:linux-arm64-v8
|