Created
July 24, 2023 12:27
-
-
Save GrillPhil/1f0697bd217583d22afedc1eda390049 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
name: secure-ng-demo | |
trigger: | |
branches: | |
include: | |
- main | |
paths: | |
exclude: | |
- docs/**/* | |
- /**/readme.md | |
variables: | |
- name: AZD_ISBRANCH_MAIN | |
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')] | |
- name: AZ_BICEP_SOURCE_FOLDER | |
value: .infra/bicep | |
- name: AZ_BICEP_FILE | |
value: main.bicep | |
- name: ARTIFACT_BICEP_DROP_NAME | |
value: drop-bicep | |
- name: ARTIFACT_BICEP_DROP_FOLDER | |
value: $(Build.ArtifactStagingDirectory)infra/bicep | |
- name: ARTIFACT_BICEP_RUN_SCRIPT_NAME | |
value: run-bicep.ps1 | |
- name: ARTIFACT_ANGULAR_DROP_NAME | |
value: drop-angular | |
- name: ARTIFACT_STATICWEBAPPCONFIG_DROP_NAME | |
value: drop-swa-config | |
pool: | |
vmImage: 'ubuntu-latest' | |
stages: | |
- stage: build | |
displayName: Build | |
jobs: | |
- job: buildInfra | |
displayName: Build Infrastructure | |
timeoutInMinutes: "15" | |
steps: | |
- checkout: self # self represents the repo where the initial Pipelines YAML file was found | |
clean: "true" # whether to fetch clean each time | |
fetchDepth: "0" # the depth of commits to ask Git to fetch | |
- script: az bicep build --file ./$(AZ_BICEP_SOURCE_FOLDER)/$(AZ_BICEP_FILE) | |
displayName: Bicep build | |
- task: CopyFiles@2 | |
displayName: 'Copy Bicep Files' | |
inputs: | |
SourceFolder: $(AZ_BICEP_SOURCE_FOLDER) | |
Contents: '**' | |
TargetFolder: $(ARTIFACT_BICEP_DROP_FOLDER) | |
- task: PublishBuildArtifacts@1 | |
displayName: Publish Bicep Artifacts | |
inputs: | |
PathtoPublish: $(ARTIFACT_BICEP_DROP_FOLDER) | |
ArtifactName: $(ARTIFACT_BICEP_DROP_NAME) | |
publishLocation: Container | |
- job: buildAngular | |
displayName: Build Angular | |
variables: | |
WORKING_DIRECTORY: src/frontend | |
PATH_TO_PUBLISH: src/frontend/dist/secure-ng-demo | |
timeoutInMinutes: "15" | |
steps: | |
- checkout: self | |
clean: "true" | |
fetchDepth: "0" | |
- task: NodeTool@0 | |
displayName: Use Node 18 | |
inputs: | |
versionSpec: '18.x' | |
- script: npm install @angular/cli | |
displayName: Install @angular/cli | |
workingDirectory: $(WORKING_DIRECTORY) | |
- script: npm install | |
displayName: Install project dependencies | |
workingDirectory: $(WORKING_DIRECTORY) | |
- script: npm run build | |
displayName: Build Angular App | |
workingDirectory: $(WORKING_DIRECTORY) | |
- task: PublishBuildArtifacts@1 | |
displayName: Publish Angular App | |
inputs: | |
PathtoPublish: $(PATH_TO_PUBLISH) | |
ArtifactName: $(ARTIFACT_ANGULAR_DROP_NAME) | |
- job: buildStaticWebAppConfig | |
displayName: Publish Static Web App Config | |
timeoutInMinutes: "15" | |
steps: | |
- task: PublishBuildArtifacts@1 | |
displayName: Publish Static Web App Config | |
inputs: | |
PathtoPublish: .infra/staticweb | |
ArtifactName: $(ARTIFACT_STATICWEBAPPCONFIG_DROP_NAME) | |
- stage: Deploy | |
displayName: Deploy | |
dependsOn: | |
- build | |
condition: succeeded() | |
variables: | |
- group: securengdemo-dev | |
jobs: | |
- deployment: deployOnDev | |
displayName: Deploy to dev | |
environment: securengdemo-dev | |
variables: | |
DEPLOYMENT_NAME: '$(AZ_DEPLOYMENT_NAME)-$(ENV_NAME)-$(Build.BuildId)' | |
workspace: | |
clean: all | |
strategy: | |
runOnce: | |
deploy: | |
steps: | |
- download: current | |
displayName: Download artifacts | |
- task: AzureCLI@2 | |
displayName: Deploy Infrastructure | |
inputs: | |
azureSubscription: securengdemo-dev | |
scriptType: pscore | |
scriptLocation: scriptPath | |
scriptPath: $(Pipeline.Workspace)/$(ARTIFACT_BICEP_DROP_NAME)/$(ARTIFACT_BICEP_RUN_SCRIPT_NAME) | |
- task: AzureCLI@2 | |
displayName: 'Get Static Web App Deployment Api Key' | |
inputs: | |
azureSubscription: securengdemo-dev | |
scriptType: bash | |
scriptLocation: inlineScript | |
inlineScript: | | |
APIKEY=$(az staticwebapp secrets list --name $(AZDPL_staticWebAppName) | jq -r '.properties.apiKey') | |
echo "##vso[task.setvariable variable=apiKey;issecret=true]$APIKEY" | |
- task: AzureStaticWebApp@0 | |
displayName: 'Deploy Static Web App' | |
inputs: | |
cwd: '$(Pipeline.Workspace)' | |
app_location: $(ARTIFACT_ANGULAR_DROP_NAME) | |
api_location: '' | |
config_file_location: $(ARTIFACT_STATICWEBAPPCONFIG_DROP_NAME) | |
skip_app_build: true | |
skip_api_build: true | |
verbose: true | |
azure_static_web_apps_api_token: $(apiKey) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment