Skip to content

azure-08-build-toolset-image #9

azure-08-build-toolset-image

azure-08-build-toolset-image #9

name: "azure-08-build-toolset-image"
on:
workflow_dispatch:
inputs:
resourceGroupName:
description: "Name of the resource group to create for Shared Image Gallery"
required: true
default: "toolset"
jobs:
create-gallery-rg:
uses: ./.github/workflows/azure-resource-group.yml
with:
resourceGroupName: ${{ github.event.inputs.resourceGroupName }}
action: create
secrets:
AZURE_AD_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }}
AZURE_AD_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_AD_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
AZURE_REGION: ${{ secrets.AZURE_REGION }}
TF_BACKEND_RESOURCE_GROUP_NAME: ${{ secrets.TF_BACKEND_RESOURCE_GROUP_NAME }}
TF_BACKEND_STORAGE_ACCOUNT_NAME: ${{ secrets.TF_BACKEND_STORAGE_ACCOUNT_NAME }}
TF_BACKEND_STORAGE_CONTAINER_NAME: ${{ secrets.TF_BACKEND_STORAGE_CONTAINER_NAME }}
create-shared-gallery-image-def:
uses: ./.github/workflows/azure-gallery.yml
needs: create-gallery-rg
with:
galleryName: toolsetvms
resourceGroupName: ${{ github.event.inputs.resourceGroupName }}
imageName: k8stoolsetvm
imageSku: "2023"
imagePublisher: workshop
imageOffer: 0000-com-vmware-k8s-toolset-vm
action: create
secrets:
AZURE_AD_CLIENT_ID: ${{ secrets.AZURE_AD_CLIENT_ID }}
AZURE_AD_CLIENT_SECRET: ${{ secrets.AZURE_AD_CLIENT_SECRET }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_AD_TENANT_ID: ${{ secrets.AZURE_AD_TENANT_ID }}
TF_BACKEND_RESOURCE_GROUP_NAME: ${{ secrets.TF_BACKEND_RESOURCE_GROUP_NAME }}
TF_BACKEND_STORAGE_ACCOUNT_NAME: ${{ secrets.TF_BACKEND_STORAGE_ACCOUNT_NAME }}
TF_BACKEND_STORAGE_CONTAINER_NAME: ${{ secrets.TF_BACKEND_STORAGE_CONTAINER_NAME }}
build:
runs-on: ubuntu-22.04
needs: create-shared-gallery-image-def
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Copy init.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/init.sh"
target: "packer/azure/ubuntu/22_04/init.sh"
- name: Copy inventory.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/inventory.sh"
target: "packer/azure/ubuntu/22_04/inventory.sh"
- name: Copy kind-load-cafile.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/kind-load-cafile.sh"
target: "packer/azure/ubuntu/22_04/kind-load-cafile.sh"
- name: Copy fetch-tanzu-cli.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/fetch-tanzu-cli.sh"
target: "packer/azure/ubuntu/22_04/fetch-tanzu-cli.sh"
- name: Copy fetch-and-install-oci-cli.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/fetch-and-install-oci-cli.sh"
target: "packer/azure/ubuntu/22_04/fetch-and-install-oci-cli.sh"
- name: Copy install-tap-plugins.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/install-tap-plugins.sh"
target: "packer/azure/ubuntu/22_04/install-tap-plugins.sh"
- name: Copy install-krew-and-plugins.sh
uses: canastro/copy-file-action@master
with:
source: "scripts/install-krew-and-plugins.sh"
target: "packer/azure/ubuntu/22_04/install-krew-and-plugins.sh"
- name: Use latest Packer
uses: hashicorp-contrib/setup-packer@v2
with:
packer-version: 1.9.1
- name: Initialize Packer
working-directory: ./packer/azure/ubuntu/22_04
run: packer init arm-ci.pkr.hcl
- name: Build image from template
working-directory: ./packer/azure/ubuntu/22_04
run: packer build -var image_name="k8stoolsetvm" -var resource_group="${{ github.event.inputs.resourceGroupName }}" -var subscription_id="${{ secrets.AZURE_SUBSCRIPTION_ID }}" -var tenant_id="${{ secrets.AZURE_AD_TENANT_ID }}" -var client_id="${{ secrets.AZURE_AD_CLIENT_ID }}" -var client_secret="${{ secrets.AZURE_AD_CLIENT_SECRET }}" -only="standard.*" arm-ci.pkr.hcl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}