Skip to content

Create files

Create files #1

Workflow file for this run

name: Export Azure resource into config
on:
push:
branches:
- '**'
- '!main'
paths:
- '.azure/export.json'
workflow_call:
inputs:
branch:
required: true
type: string
permissions:
contents: write
id-token: write
env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_USE_OIDC: true
TF_VAR_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
TF_VAR_hci_0_local_admin_user: ${{ secrets.localAdminUser }}
TF_VAR_hci_0_local_admin_password: ${{ secrets.localAdminPassword }}
TF_VAR_domain_admin_user: ${{ secrets.domainAdminUser }}
TF_VAR_domain_admin_password: ${{ secrets.domainAdminPassword }}
TF_VAR_hci_0_deployment_user_password: ${{ secrets.deploymentUserPassword }}
TF_VAR_hci_0_service_principal_id: ${{ secrets.servicePrincipalId }}
TF_VAR_hci_0_service_principal_secret: ${{ secrets.servicePrincipalSecret }}
TF_VAR_rp_service_principal_object_id: ${{ secrets.rpServicePrincipalObjectId }}
TF_VAR_vm_admin_password: ${{ secrets.vmAdminPassword }}
TF_VAR_domain_join_password: ${{ secrets.domainJoinPassword }}
HCI_RP_SP_ID: ${{ secrets.rpServicePrincipalObjectId }}
jobs:
export:
environment: terraform
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# checkout to input branch when input branch is not empty
- name: Checkout to input branch
if: ${{ inputs.branch != '' }}
run: |
git fetch origin ${{ inputs.branch }}
git checkout ${{ inputs.branch }}
# Install node
- uses: actions/setup-node@v4
with:
node-version: latest
- run: node --version
# Install the latest version of Terraform CLI
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
# check terraform version
- name: Check terraform version
run: terraform version
# az login
- name: Log in to Azure using OIDC
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# check first 18 characters of az account user name
- name: Check az account
run: az account show --query user.name --output tsv | cut -c 1-18
# Download az-edge-module-export
- name: Download az-edge-module-export
run: |
wget "https://aka.ms/az-edge-module-export-linux-amd64" -O az-edge-module-export
chmod +x az-edge-module-export
./az-edge-module-export -v
# Download az-edge-site-scale
- name: Download az-edge-site-scale
run: |
wget "https://aka.ms/az-edge-site-scale-linux-amd64" -O az-edge-site-scale
chmod +x az-edge-site-scale
./az-edge-site-scale -v
# Run az-edge-module-export
- name: Run az-edge-module-export
run: |
./az-edge-module-export -c ./.azure/export.json -b ./.azure/backendTemplate.tf
rm ./az-edge-module-export
# Generate sample csv file to scale
- name: Run az-edge-site-scale generate
run: |
mkdir -p ./.azure/scale
cat ./.azure/export.json | jq -r '.[]|[.baseModulePath, .groupPath] | @tsv' |
while IFS=$'\t' read -r baseModulePath groupPath; do
name=$(echo $baseModulePath | rev | cut -d '/' -f 1 | rev)
./az-edge-site-scale generate -c ./.azure/scale/$name.csv -s $groupPath
done
rm ./az-edge-site-scale
- name: Clean up
run: |
rm ./.azure/export.json
# Commit and push the changes
- name: Commit and push the changes
if: always()
run: |
git config --global user.email "[email protected]"
git config --global user.name "IaC Exporter"
git add .
git commit -m "Export Azure resource into config"
git push