Skip to content

Merge pull request #7 from ldm0206/main #1

Merge pull request #7 from ldm0206/main

Merge pull request #7 from ldm0206/main #1

name: Build and Push Docker Images
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: desktop
context: ./docker
file: ./docker/Dockerfile
- name: gateway
context: .
file: ./gateway/Dockerfile
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Compute lowercase image name
id: img
run: |
echo "base=${REGISTRY}/$(echo '${{ github.repository }}-${{ matrix.name }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.img.outputs.base }}
tags: |
type=raw,value=latest
type=sha,prefix=
- name: Build and push ${{ matrix.name }} image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
file: ${{ matrix.file }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ matrix.name }}