Skip to content

Commit

Permalink
moved from bicep to yaml for resource group suffix (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
Physer authored Jun 7, 2024
1 parent 039abf1 commit 59d4be1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ jobs:
name: Apply infrastructure
uses: ./.github/workflows/reusable-apply-infrastructure.yaml
with:
suffix: ${{ github.head_ref }}
environment: preview
cloudSubDomain: ${{ needs.create-subdomain-hash.outputs.subdomainHash }}.cloud
dotnetSubDomain: ${{ needs.create-subdomain-hash.outputs.subdomainHash }}.dotnet
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/reusable-apply-infrastructure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ on:
dotnetSubDomain:
required: true
type: string
suffix:
required: true
type: string
outputs:
cloudStorageAccount:
value: ${{ jobs.apply-infrastructure.outputs.cloudStorageAccount }}
Expand Down Expand Up @@ -43,14 +40,19 @@ jobs:
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Slugify Github variables
uses: rlespinasse/github-slug-action@v4
with:
slug-maxlength: 50

- name: Deploy Bicep file
id: deploybicep
uses: azure/arm-deploy@v2
with:
scope: subscription
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
template: ./infrastructure/websiteDeploy.bicep
parameters: "suffix=${{ inputs.suffix }} cloudSubDomain=${{ inputs.cloudSubDomain }} dotnetSubDomain=${{ inputs.dotnetSubDomain }}"
parameters: "resourceGroupSuffix=${{ env.GITHUB_REF_NAME_SLUG }} cloudSubDomain=${{ inputs.cloudSubDomain }} dotnetSubDomain=${{ inputs.dotnetSubDomain }}"
region: westeurope

- name: Comment Website FQDNs on Pull Requests
Expand Down
8 changes: 6 additions & 2 deletions infrastructure/websiteDeploy.bicep
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
targetScope = 'subscription'

param suffix string
param resourceGroupSuffix string
param frontDoorProfileName string = 'afd-xprtzbv-websites'
param rootDomain string = 'xprtz.dev'
param dotnetSubDomain string
param cloudSubDomain string

var resourceGroupPrefix = 'rg-xprtzbv-website'
var resourceGroupName = endsWith(resourceGroupSuffix, 'main')
? resourceGroupPrefix
: '${resourceGroupPrefix}-${resourceGroupSuffix}'
var dotnetApplicationName = 'dotnet'
var cloudApplicationName = 'cloud'

Expand All @@ -18,7 +22,7 @@ var infrastructureResourceGroup = resourceGroup(

resource websiteResourceGroup 'Microsoft.Resources/resourceGroups@2024-03-01' = {
location: deployment().location
name: 'rg-xprtzbv-website-${uniqueString(suffix)}'
name: resourceGroupName
}

module cloudStorageAccountModule 'modules/storageAccount.bicep' = {
Expand Down

0 comments on commit 59d4be1

Please sign in to comment.