Skip to content

Build and publish to MCR #18

Build and publish to MCR

Build and publish to MCR #18

# This Github action builds and publishes image to Azure Container Registry (ACR),
# from where it is automatically propagated to Microsoft Container Registry (MCR).
name: Build and publish to MCR
on:
workflow_dispatch:
inputs:
releaseTag:
description: 'Release tag to publish, defaults to the latest one'
type: string
permissions:
contents: read
env:
REGISTRY_REPO: public/aks/karpenter
jobs:
prepare-variables:
runs-on:
labels: [self-hosted, "1ES.Pool=${{ vars.RELEASE_1ES_POOL }}"]
outputs:
release_tag: ${{ steps.vars.outputs.release_tag }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
fetch-depth: 0
- name: 'Set output variables'
id: vars
run: |
RELEASE_TAG=${{ inputs.releaseTag }}
if [ -z "$RELEASE_TAG" ]; then
RELEASE_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")"
echo "The user input release tag is empty, will use the latest tag $RELEASE_TAG."
fi
echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT"
publish-images:
permissions:
contents: read
id-token: write # This is required for requesting the JWT
runs-on:
labels: [self-hosted, "1ES.Pool=${{ vars.RELEASE_1ES_POOL }}"]
needs: prepare-variables
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ needs.prepare-variables.outputs.release_tag }}
- uses: ./.github/actions/install-deps
- name: Build and publish image
env:
KO_DOCKER_REPO: ${{ secrets.AZURE_REGISTRY }}/${{ env.REGISTRY_REPO }}
run: |
az login --identity
az acr login -n ${{ secrets.AZURE_REGISTRY }}
cat >.ko.yaml <<EOF
builds:
- id: controller
main: ./cmd/controller
flags: ['-tags','ccp']
EOF
ko build github.com/Azure/karpenter-provider-azure/cmd/controller \
--push=false \
--platform linux/amd64,linux/arm64 \
--base-import-paths \
--sbom none \
--tags ${{ needs.prepare-variables.outputs.release_tag }}-aks