chore(deps): update actions/checkout digest to 11bd719 #73
This file contains 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 Image | |
on: | |
pull_request: | |
branches: [ main ] | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: bojanzelic/cloudflare-zero-trust-operator | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
build: [ | |
{platform: linux/amd64, cache: amd64}, | |
{platform: linux/arm64, cache: arm64}, | |
] | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
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 | |
with: | |
platforms: ${{ matrix.build.platform }} | |
- 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 for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha,prefix=sha- | |
type=ref,event=tag | |
# For pull requests, build and push platform-specific images | |
- name: Build and push Docker image | |
if: github.event_name == 'pull_request' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.build.platform }} | |
push: true | |
tags: ${{ steps.meta.outputs.tags }}-${{ matrix.build.cache }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: | | |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.build.cache }} | |
cache-to: | | |
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.build.cache }},mode=max | |
merge-manifests: | |
needs: build | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- 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 for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=sha,prefix=sha- | |
type=ref,event=tag | |
- name: Create and push manifest list | |
run: | | |
# Get the tag without the registry prefix | |
TAG=$(echo "${{ steps.meta.outputs.tags }}" | head -n1) | |
MANIFEST_IMAGES="" | |
for CACHE in "amd64" "arm64"; do | |
MANIFEST_IMAGES="$MANIFEST_IMAGES ${TAG}-$CACHE" | |
done | |
# Trim leading space from MANIFEST_IMAGES | |
MANIFEST_IMAGES="${MANIFEST_IMAGES# }" | |
echo $MANIFEST_IMAGES | |
docker buildx imagetools create -t ${TAG} ${MANIFEST_IMAGES} | |
tag-release: | |
needs: build | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
steps: | |
- 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 commit SHA | |
id: sha | |
run: echo "sha=$(echo ${{ github.sha }})" >> $GITHUB_OUTPUT | |
- name: Create release manifest lists | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
# Create manifest lists for both version tag and latest | |
for TAG in "$VERSION" "latest"; do | |
MANIFEST_IMAGES="" | |
for CACHE in "amd64" "arm64"; do | |
MANIFEST_IMAGES="$MANIFEST_IMAGES ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:sha-${{ steps.sha.outputs.sha }}-$CACHE" | |
done | |
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$TAG $MANIFEST_IMAGES | |
done |