-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move infrastructure to repo and set up pipelines (#13)
* Move infrastructure code to shifty, add pipeline fix workflow call fix dependency fix dependency pt 2 Actually add environment * Add CNAME and Custom Domain to Bicep * Add target branch parameter to bicep * Remove redundant shared module * Use existing keyword on dns and resource group * Move towards release-based workflow
- Loading branch information
Showing
11 changed files
with
280 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: Deploy to dev | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
dev-deploy: | ||
uses: ./.github/workflows/deploy.yml | ||
secrets: inherit | ||
with: | ||
environment: dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: Deploy to prd | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
prd-deploy: | ||
uses: ./.github/workflows/deploy.yml | ||
secrets: inherit | ||
with: | ||
environment: prd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Build ARM template | ||
|
||
on: | ||
workflow_call: | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Build ARM template | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build ARM template | ||
uses: Azure/[email protected] | ||
with: | ||
bicepFilePath: infrastructure/azuredeploy.bicep | ||
outputFilePath: azuredeploy.json | ||
|
||
- name: Store ARM template | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: arm | ||
path: azuredeploy.json | ||
retention-days: 1 | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build Webapp | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
workflow_call: | ||
inputs: | ||
publish_artifacts: | ||
description: "Publish workflow artifacts" | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
build-test: | ||
name: Build and test Webapp | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout codebase | ||
uses: actions/checkout@v3 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.x | ||
- name: Restore dependencies | ||
run: dotnet restore . | ||
- name: Build Shifty App | ||
run: dotnet build . --no-restore /p:ContinuousIntegrationBuild=true --configuration Release | ||
- name: Run tests | ||
run: dotnet test . --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=opencover | ||
- name: Publish Shifty App | ||
run: dotnet publish --no-restore --configuration Release --output publish | ||
- name: Publish workflow artifact | ||
if: ${{ inputs.publish_artifacts }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: shifty | ||
path: publish/wwwroot | ||
retention-days: 1 | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"yaml.schemas": { | ||
"https://json.schemastore.org/github-workflow.json": "file:///c%3A/Users/andre/Projects/school/analogio/shifty-webapp/.github/workflows/deploy.yml" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
targetScope = 'subscription' | ||
|
||
@allowed([ 'dev', 'prd' ]) | ||
param environment string | ||
|
||
var location = 'West Europe' | ||
|
||
var organizationPrefix = 'aio' | ||
var sharedResourcesAbbreviation = 'shr' | ||
var webAppResourcesAbbreviation = 'app' | ||
|
||
resource sharedRg 'Microsoft.Resources/resourceGroups@2022-09-01' existing = { | ||
name: 'rg-${organizationPrefix}-${sharedResourcesAbbreviation}-${environment}' | ||
} | ||
|
||
resource shiftyRg 'Microsoft.Resources/resourceGroups@2022-09-01' = { | ||
name: 'rg-${organizationPrefix}-${webAppResourcesAbbreviation}-shifty-${environment}' | ||
location: location | ||
} | ||
|
||
module shiftywebapp 'shifty.bicep' = { | ||
name: '${deployment().name}-app-shifty' | ||
scope: shiftyRg | ||
params: { | ||
location: location | ||
organizationPrefix: organizationPrefix | ||
applicationPrefix: 'shifty' | ||
environment: environment | ||
sharedResourceGroupName: sharedRg.name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"analyzers": { | ||
"core": { | ||
"enabled": true, | ||
"verbose": false, | ||
"rules": { | ||
"adminusername-should-not-be-literal": { | ||
"level": "error" | ||
}, | ||
"no-hardcoded-env-urls": { | ||
"level": "error" | ||
}, | ||
"no-unnecessary-dependson": { | ||
"level": "error" | ||
}, | ||
"no-unused-params": { | ||
"level": "error" | ||
}, | ||
"no-unused-vars": { | ||
"level": "error" | ||
}, | ||
"outputs-should-not-contain-secrets": { | ||
"level": "error" | ||
}, | ||
"prefer-interpolation": { | ||
"level": "error" | ||
}, | ||
"secure-parameter-default": { | ||
"level": "error" | ||
}, | ||
"simplify-interpolation": { | ||
"level": "error" | ||
}, | ||
"use-protectedsettings-for-commandtoexecute-secrets": { | ||
"level": "error" | ||
}, | ||
"use-stable-vm-image": { | ||
"level": "error" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
param environment string | ||
|
||
param webappAzureGeneratedFqdn string | ||
|
||
resource zone 'Microsoft.Network/dnsZones@2018-05-01' existing = { | ||
name: '${environment}.analogio.dk' | ||
} | ||
|
||
resource cname 'Microsoft.Network/dnsZones/CNAME@2018-05-01' = { | ||
name: 'shifty' | ||
parent: zone | ||
properties: { | ||
TTL: 3600 | ||
CNAMERecord: { | ||
cname: webappAzureGeneratedFqdn | ||
} | ||
} | ||
} | ||
|
||
output customDomainFqdn string = cname.properties.fqdn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
param location string = resourceGroup().location | ||
|
||
param environment string | ||
|
||
param organizationPrefix string | ||
param applicationPrefix string | ||
|
||
param sharedResourceGroupName string | ||
|
||
resource staticwebapp 'Microsoft.Web/staticSites@2022-03-01' = { | ||
name: 'stapp-${organizationPrefix}-${applicationPrefix}-${environment}' | ||
location: location | ||
sku: { | ||
name: 'Free' | ||
tier: 'Free' | ||
} | ||
properties: { | ||
allowConfigFileUpdates: false | ||
repositoryUrl: 'https://github.com/AnalogIO/shifty-webapp' | ||
branch: 'develop' | ||
provider: 'GitHub' | ||
stagingEnvironmentPolicy: 'Disabled' | ||
enterpriseGradeCdnStatus: 'Disabled' | ||
} | ||
} | ||
|
||
module dns 'modules/dns.bicep' = { | ||
name: '${deployment().name}-dns' | ||
scope: resourceGroup(sharedResourceGroupName) | ||
params: { | ||
environment: environment | ||
webappAzureGeneratedFqdn: staticwebapp.properties.defaultHostname | ||
} | ||
} | ||
|
||
resource staticwebappCustomDomain 'Microsoft.Web/staticSites/customDomains@2022-03-01' = { | ||
name: 'shifty.${environment}.analogio.dk' | ||
parent: staticwebapp | ||
} |