Skip to content

Feat: push container image to Github Registry #36

Feat: push container image to Github Registry

Feat: push container image to Github Registry #36

Workflow file for this run

name: push-latest
#
on:
# Allow manual trigger on default branch
workflow_dispatch:
# Trigger selected on PR events
pull_request:
types: [synchronize, opened, reopened, ready_for_review]
# Trigger on push to master only on Dockerfile related modifications
push:
branches:
- "master"
paths:
- "Dockerfile"
- "supported_versions.json"
- "hashicorp.asc"
- "tests/**"
- ".dockerignore"
- ".github/workflows/push-latest.yml"
env:
IMAGE_NAME: "zenika/terraform-azure-cli"
REGISTRY: ghcr.io
jobs:
build_push_latest:
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Retrieve latest suported versions
run: |
echo "AZ_VERSION=$(jq -r '.azcli_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
echo "TF_VERSION=$(jq -r '.tf_version | sort | .[-1]' supported_versions.json)" >> $GITHUB_ENV
- 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: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build and push container images
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386
build-args: |
TERRAFORM_VERSION=${{ env.TF_VERSION }}
AWS_CLI_VERSION=${{ env.AWS_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max