Skip to content

Test

Test #26

name: Build Docker Image
on:
push:
branches: [main, test]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
base_image: [alpine, debian]
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Determine Base Tags
shell: bash
run: |
if [[ "${{ github.ref_name }}" == "main" ]]; then
echo "BASE_TAGS=latest" | tee -a "${GITHUB_ENV}"
else
echo "BASE_TAGS=${{ github.ref_name }}" | tee -a "${GITHUB_ENV}"
fi
- name: Bake ${{ matrix.base_image }} containers
uses: docker/bake-action@v4
env:
BASE_TAGS: "${{ env.BASE_TAGS }}"
CONTAINER_REGISTRIES: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
SOURCE_REPOSITORY_URL: "${{ github.server_url }}/${{ github.repository }}"
SOURCE_VERSION: ${{ github.sha }}
VW_VERSION: ${{ github.sha }}
with:
push: true
files: docker/docker-bake.hcl
targets: ${{ matrix.base_image }}-multi
set: |
*.platform=linux/amd64,linux/arm64
*.cache-from=type=gha
*.cache-to=type=gha,mode=max