Skip to content

Commit

Permalink
Merge pull request #5382 from dfe-analytical-services/ees-5618
Browse files Browse the repository at this point in the history
EES-5618 Cleanup public API infrastructure pipeline
  • Loading branch information
ntsim authored Nov 11, 2024
2 parents c31ad04 + 6ca7f18 commit 3a95111
Show file tree
Hide file tree
Showing 11 changed files with 479 additions and 453 deletions.
136 changes: 0 additions & 136 deletions infrastructure/templates/public-api/api-infrastructure-pipeline.yml

This file was deleted.

84 changes: 84 additions & 0 deletions infrastructure/templates/public-api/ci/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
trigger: none

parameters:
- name: deployContainerApp
displayName: Can we deploy the Container App yet? This is dependent on the PostgreSQL Flexible Server being set up and having users manually added.
default: true
- name: updatePsqlFlexibleServer
displayName: Does the PostgreSQL Flexible Server require any updates? False by default to avoid unnecessarily lengthy deploys.
default: false
- name: forceDeployToEnvironment
displayName: Set to either dev or test to force a deploy to that environment from the chosen branch.
type: string
values:
- none
- dev
- test
default: 'none'

resources:
pipelines:
- pipeline: MainBuild
source: Explore Education Statistics
trigger:
branches:
- dev
- test
- master

variables:
- group: Public API Infrastructure - Common
- name: forceDeployToEnvironment
value: ${{parameters.forceDeployToEnvironment}}
- name: isDev
value: $[or(eq(variables['forceDeployToEnvironment'], 'dev'), eq(variables['Build.SourceBranch'], 'refs/heads/dev'))]
- name: isTest
value: $[or(eq(variables['forceDeployToEnvironment'], 'test'), eq(variables['Build.SourceBranch'], 'refs/heads/test'))]
- name: isMaster
value: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
- name: vmImageName
value: ubuntu-latest
- name: deployContainerApp
value: ${{ parameters.deployContainerApp }}
- name: updatePsqlFlexibleServer
value: ${{ parameters.updatePsqlFlexibleServer }}

pool:
vmImage: $(vmImageName)

stages:
- template: stages/deploy.yml
parameters:
stageName: DeployDev
condition: eq(variables.isDev, true)
environment: Dev
serviceConnection: $(serviceConnectionDev)
bicepParamFile: dev

- template: stages/deploy.yml
parameters:
stageName: DeployTest
condition: eq(variables.isTest, true)
dependsOn: DeployDev
environment: Test
serviceConnection: $(serviceConnectionTest)
bicepParamFile: test

# - template: stages/deploy.yml
# parameters:
# stageName: DeployPreProd
# condition: eq(variables.isMaster, true)
# trigger: manual
# environment: Pre-Prod
# serviceConnection: $(serviceConnectionPreProd)
# bicepParamFile: preprod
#
# - template: stages/deploy.yml
# parameters:
# stageName: DeployProd
# condition: and(succeeded(), eq(variables.isMaster, true))
# trigger: manual
# dependsOn: DeployPreProd
# environment: Prod
# serviceConnection: $(serviceConnectionProd)
# bicepParamFile: prod
54 changes: 54 additions & 0 deletions infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
parameters:
- name: serviceConnection
type: string
- name: environment
type: string
- name: dependsOn
type: object
default: []

jobs:
- deployment: DeployPublicApiDocs
displayName: Deploy Public API docs
dependsOn: ${{ parameters.dependsOn }}
environment: ${{ parameters.environment }}
strategy:
runOnce:
deploy:
steps:
# Workaround for deprecation warning preventing deployment token for
# API docs from being fetched: https://github.com/Azure/azure-cli/issues/30048
- task: Bash@3
name: InstallAzureCLI
displayName: Install Azure CLI 2.64.0 as workaround
inputs:
targetType: inline
script: |
set -e
pip install --force-reinstall azure-cli==2.64.0
- task: AzureCLI@2
displayName: Get deployment token
inputs:
azureSubscription: ${{ parameters.serviceConnection }}
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
deploymentToken=`az staticwebapp secrets list -n $(docsAppName) --query "properties.apiKey" -o tsv`
echo "##vso[task.setvariable variable=docsDeploymentToken;]$deploymentToken"
- download: MainBuild
displayName: Download Public API docs artifact
artifact: public-api-docs

- task: AzureStaticWebApp@0
displayName: Deploy API docs
inputs:
app_location: /
output_location: '' # Leave this empty
skip_app_build: true
skip_api_build: true
azure_static_web_apps_api_token: $(docsDeploymentToken)
cwd: $(Pipeline.Workspace)/MainBuild/public-api-docs

Loading

0 comments on commit 3a95111

Please sign in to comment.