From 67a5e65f06bae4a27ba7a16f21984ce246776945 Mon Sep 17 00:00:00 2001 From: Gerd Oberlechner Date: Thu, 24 Oct 2024 12:08:00 +0200 Subject: [PATCH] azure cli gh action Signed-off-by: Gerd Oberlechner --- .github/actions/install-azure-cli/action.yml | 14 ++++++ .github/actions/templatize.yml | 46 +++++++++++++++++++ .../workflows/aro-hcp-dev-bicep-what-if.yml | 24 +++++----- .github/workflows/cs-pr-bicep-what-if.yml | 24 +++++----- 4 files changed, 84 insertions(+), 24 deletions(-) create mode 100644 .github/actions/install-azure-cli/action.yml create mode 100644 .github/actions/templatize.yml diff --git a/.github/actions/install-azure-cli/action.yml b/.github/actions/install-azure-cli/action.yml new file mode 100644 index 000000000..9ac97ac54 --- /dev/null +++ b/.github/actions/install-azure-cli/action.yml @@ -0,0 +1,14 @@ +name: Install azure-cli +description: Installs the azure cli. +runs: + using: composite + steps: + - name: install azure-cli + run: | + sudo apt-get install -y ca-certificates curl apt-transport-https lsb-release gnupg + curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null + AZ_REPO=$(lsb_release -cs) + echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | sudo tee /etc/apt/sources.list.d/azure-cli.list + sudo apt-get update + sudo apt-get install -y azure-cli=2.64.0 + shell: bash diff --git a/.github/actions/templatize.yml b/.github/actions/templatize.yml new file mode 100644 index 000000000..0e5b5a660 --- /dev/null +++ b/.github/actions/templatize.yml @@ -0,0 +1,46 @@ +name: 'Azure CLI, Go, and Make' +description: 'Install Azure CLI, Go, and Make, and run a script' +runs: + using: 'composite' + steps: + - name: 'Prepare workspace' + run: mkdir -p /workspace/bin + + - name: 'Copy Azure CLI' + uses: docker://mcr.microsoft.com/azure-cli:2.64.0 + with: + args: | + /bin/bash -c " + cp -r /usr/local/bin/az /workspace/bin/ && + cp -r /usr/local/az /workspace/bin/ + " + volumes: + - name: workspace + path: /workspace + + - name: 'Build templatize' + uses: docker://golang:1.23 + with: + args: | + /bin/bash -c " + go build -o /workspace/templatize ./tooling/templatize + " + env: + GO111MODULE: 'on' + volumes: + - name: workspace + path: /workspace + + - name: 'Install Make' + run: | + sudo apt-get update + sudo apt-get install -y make + + - name: 'Run script' + run: ${{ inputs.script }} + shell: bash + +inputs: + script: + description: 'The script to run' + required: true diff --git a/.github/workflows/aro-hcp-dev-bicep-what-if.yml b/.github/workflows/aro-hcp-dev-bicep-what-if.yml index 55bf8e408..4ea502d10 100644 --- a/.github/workflows/aro-hcp-dev-bicep-what-if.yml +++ b/.github/workflows/aro-hcp-dev-bicep-what-if.yml @@ -30,16 +30,16 @@ jobs: tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Install Azure CLI + uses: ./.github/actions/install-azure-cli + - name: 'Deployment What If' - uses: azure/cli@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # v2.1.0 - with: - azcliversion: 2.63.0 - inlineScript: | - dev-infrastructure/make ${DEPLOY_ENV} acr.what-if - dev-infrastructure/make ${DEPLOY_ENV} acr-svc.what-if - dev-infrastructure/make ${DEPLOY_ENV} acr-ocp.what-if - dev-infrastructure/make ${DEPLOY_ENV} region.what-if - dev-infrastructure/make ${DEPLOY_ENV} svc.what-if - dev-infrastructure/make ${DEPLOY_ENV} mgmt.what-if - dev-infrastructure/make ${DEPLOY_ENV} metrics-infra.what-if - dev-infrastructure/make ${DEPLOY_ENV} image-sync.what-if + run: | + dev-infrastructure/make ${DEPLOY_ENV} acr.what-if + dev-infrastructure/make ${DEPLOY_ENV} acr-svc.what-if + dev-infrastructure/make ${DEPLOY_ENV} acr-ocp.what-if + dev-infrastructure/make ${DEPLOY_ENV} region.what-if + dev-infrastructure/make ${DEPLOY_ENV} svc.what-if + dev-infrastructure/make ${DEPLOY_ENV} mgmt.what-if + dev-infrastructure/make ${DEPLOY_ENV} metrics-infra.what-if + dev-infrastructure/make ${DEPLOY_ENV} image-sync.what-if diff --git a/.github/workflows/cs-pr-bicep-what-if.yml b/.github/workflows/cs-pr-bicep-what-if.yml index 50f63babb..7771eb5ff 100644 --- a/.github/workflows/cs-pr-bicep-what-if.yml +++ b/.github/workflows/cs-pr-bicep-what-if.yml @@ -30,16 +30,16 @@ jobs: tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Install Azure CLI + uses: ./.github/actions/install-azure-cli + - name: 'Deployment What If' - uses: azure/cli@089eac9d8cc39f5d003e94f8b65efc51076c9cbd # v2.1.0 - with: - azcliversion: 2.63.0 - inlineScript: | - dev-infrastructure/make ${DEPLOY_ENV} acr.what-if - dev-infrastructure/make ${DEPLOY_ENV} acr-svc.what-if - dev-infrastructure/make ${DEPLOY_ENV} acr-ocp.what-if - dev-infrastructure/make ${DEPLOY_ENV} region.what-if - dev-infrastructure/make ${DEPLOY_ENV} svc.what-if - dev-infrastructure/make ${DEPLOY_ENV} mgmt.what-if - dev-infrastructure/make ${DEPLOY_ENV} metrics-infra.what-if - dev-infrastructure/make ${DEPLOY_ENV} image-sync.what-if + run: | + dev-infrastructure/make ${DEPLOY_ENV} acr.what-if + dev-infrastructure/make ${DEPLOY_ENV} acr-svc.what-if + dev-infrastructure/make ${DEPLOY_ENV} acr-ocp.what-if + dev-infrastructure/make ${DEPLOY_ENV} region.what-if + dev-infrastructure/make ${DEPLOY_ENV} svc.what-if + dev-infrastructure/make ${DEPLOY_ENV} mgmt.what-if + dev-infrastructure/make ${DEPLOY_ENV} metrics-infra.what-if + dev-infrastructure/make ${DEPLOY_ENV} image-sync.what-if