Skip to content

Commit

Permalink
Let's just run PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Oct 9, 2023
1 parent efe7726 commit 14ec8df
Showing 1 changed file with 27 additions and 35 deletions.
62 changes: 27 additions & 35 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ permissions:

jobs:
deploy-bicep:
runs-on: ubuntu-latest
name: Deploy Bicep
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

Expand All @@ -24,41 +25,32 @@ jobs:
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true

# Why on earth can't I just deploy the bicep file?
- uses: azure/[email protected]
name: Bicep Build
with:
bicepFilePath: infrastructure/Cluster.bicep
outputFilePath: infrastructure/Cluster.json
- name: Run Azure PowerShell script
uses: azure/powershell@v1
with:
inlineScript: |
$Results = New-AzResourceGroupDeployment -Name "aks-$(Get-Date -f yyyyMMddThhmmss)" -ResourceGroupName $Env:RESOURCEGROUP -TemplateFile infrastructure/Cluster.bicep -TemplateParameterObject @{ adminId = $Env:ADMINS }
- id: name
shell: pwsh
run: '"name=aks-$(Get-Date -f yyyyMMddThhmmss)" >> $Env:GITHUB_OUTPUT'
$Results | Out-Host
- uses: azure/arm-deploy@v1
name: deploy
timeout-minutes: 240
with:
template: infrastructure/Cluster.json
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG }}
parameters: adminId=${{ secrets.ADMIN_GROUP_ID }}
deploymentName: ${{ steps.name.outputs.name }}
#! Get the cluster credentials
Get-AzAksCluster -ResourceGroupName $Env:RESOURCEGROUP |
Import-AzAksCredential -Force
#! Update the client ID from the deployment output
$kustomize = Get-Content "clusters/poschode/flux/kustomization.ps1"
$kustomize = $kustomize -replace "azure.workload.identity/client-id: .*$", "azure.workload.identity/client-id: $($Results.Outputs.fluxIdClientId)"
# TODO: commit this file to the repo _before_ running flux
$kustomize | Set-Content "clusters/poschode/flux/kustomization.ps1"
#! Bootstrap Flux
./infrastructure/Install-Flux.ps1
- id: deploy-flux
shell: pwsh
run: |
#! Get the cluster credentials
Get-AzAksCluster -ResourceGroupName $Env:RESOURCE_GROUP |
Import-AzAksCredential -Force
#! Update the client ID from the deployment output
$kustomize = Get-Content "clusters/poschode/flux/kustomization.ps1"
$kustomize = $kustomize -replace "azure.workload.identity/client-id: .*$", "azure.workload.identity/client-id: ${{ steps.deploy.outputs.fluxIdClientId }}"
# TODO: commit this file to the repo _before_ running flux
$kustomize | Set-Content "clusters/poschode/flux/kustomization.ps1"
#! Bootstrap Flux
./infrastructure/Install-Flux.ps1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RESOURCE_GROUP: ${{ secrets.AZURE_RG }}
azPSVersion: "latest"
env:
SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
RESOURCEGROUP: ${{ secrets.AZURE_RG }}
ADMINS: ${{ secrets.ADMIN_GROUP_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 14ec8df

Please sign in to comment.