Build and publish containerization test images #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish containerization test images | |
on: | |
workflow_dispatch: | |
inputs: | |
publish: | |
type: boolean | |
description: "Publish the built image" | |
default: false | |
version: | |
type: string | |
description: "Version of the image to create" | |
default: "test" | |
image: | |
type: choice | |
description: Test image to build | |
options: | |
- dockermanifestimage | |
- emptyimage | |
default: 'dockermanifestimage' | |
useBuildx: | |
type: boolean | |
description: "Use docker buildx to build the image" | |
default: false | |
jobs: | |
image: | |
name: Build test images | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Check branch | |
run: | | |
if [ ${{ github.ref }} != 'refs/heads/main' ] && [ ${{ github.ref }} != 'ref/heads/release*'] && [ ${{ inputs.publish }} == true ]; then | |
echo "Cannot publish an image if we are not on main or a release branch." | |
exit 1 | |
fi | |
- name: Check inputs | |
run: | | |
if [ ${{ inputs.image }} == 'dockermanifestimage' ] && [ ${{ inputs.useBuildx }} == true ]; then | |
echo "dockermanifestimage cannot be built with buildx" | |
exit 1 | |
fi | |
if [ ${{ inputs.image }} == 'emptyimage' ] && [ ${{ inputs.useBuildx}} != true ]; then | |
echo "emptyimage should be built with buildx" | |
exit 1 | |
fi | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
if: ${{ inputs.useBuildx }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Build dockerfile and push image | |
uses: docker/build-push-action@v6 | |
with: | |
push: ${{ inputs.publish }} | |
context: Tests/TestImages/${{ inputs.image }} | |
tags: ghcr.io/apple/containerization/${{ inputs.image }}:${{ inputs.version }} |