Skip to content

build and push to acr #23

build and push to acr

build and push to acr #23

name: build and push to acr
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to build'
required: true
default: 'development'
type: choice
options:
- development
- staging
- prod
permissions:
contents: read
jobs:
docker:
strategy:
matrix:
include:
- components: devhostagent
imageName: lpkremoteagent
- components: devhostagent.restorationjob
imageName: lpkrestorationjob
- components: routingmanager
imageName: routingmanager
environment: ${{ github.event.inputs.environment }}
runs-on:
labels: ["self-hosted", "1ES.Pool=${{ vars.RUNNER_BASE_NAME }}-${{ github.event.inputs.environment }}-ubuntu"]
steps:
- name: Harden Runner
uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
- name: Authenticate to ACR
run : |
az login --identity
az acr login -n ${{ vars.AZURE_REGISTRY_SERVER }}
- name: Set telemetry variables
shell: bash
run: |
if [ $GITHUB_REF == "refs/heads/main" ]; then
echo "##vso[task.setvariable variable=TelemetryType]TELEMETRY_PRODUCTION"
else
echo "##vso[task.setvariable variable=TelemetryType]TELEMETRY_DEVELOPMENT"
fi
- name: Set image tags
shell: bash
id: version
run: |
chmod +x ./deployment/settings/setenvironmentvariables.sh
`./deployment/settings/setenvironmentvariables.sh deployment/settings/services/imagetag.setting`
printenv | grep "MINDARO"
if [ ${{ matrix.components}} == "devhostagent" ]; then
echo "tag=$MINDARO_DEVHOSTAGENT_TAG" >> $GITHUB_ENV
elif [ ${{ matrix.components}} == "devhostagent.restorationjob" ]; then
echo "tag=$MINDARO_DEVHOSTAGENT_RESTORATIONJOB_TAG" >> $GITHUB_ENV
else
echo "tag=stable" >> $GITHUB_ENV
fi
- name: Build and push for ${{ matrix.components }}
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
with:
file: src/${{ matrix.components }}/Dockerfile
platforms: linux/arm64,linux/amd64
push: true
tags: ${{ vars.AZURE_REGISTRY_SERVER }}/${{ matrix.imageName }}:${{ env.tag }}