Skip to content

Commit

Permalink
fixup! EES-5396 Update public API docs to use generated OpenAPI docs …
Browse files Browse the repository at this point in the history
…when deploying
  • Loading branch information
ntsim committed Dec 19, 2024
1 parent 0100327 commit 43befe7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 19 deletions.
43 changes: 29 additions & 14 deletions azure-pipelines-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,6 @@ jobs:
command: push
tags: $(Build.BuildNumber)

- task: PublishPipelineArtifact@1
displayName: Publish Public API docs artifact
inputs:
artifactName: public-api-docs
targetPath: $(System.DefaultWorkingDirectory)/src/$(PublicApiDocsDir)

- task: DotNetCoreCLI@2
displayName: Package Public API Data Processor Function
inputs:
Expand Down Expand Up @@ -320,7 +314,7 @@ jobs:
projects: '**/GovUk.Education.ExploreEducationStatistics.Admin.csproj'
arguments: --self-contained true -r win-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)

- task: PublishPipelineArtifact@0
- task: PublishPipelineArtifact@1
condition: and(succeeded(), eq(variables.IsBranchDeployable, true))
displayName: Publish Admin artifact
inputs:
Expand Down Expand Up @@ -435,23 +429,44 @@ jobs:
inputs:
versionSpec: '>= $(RubyVersion)'

- task: Cache@2
displayName: Cache Gems
inputs:
key: 'gems | "$(Agent.OS)" | $(WorkingDirectory)/Gemfile.lock'
path: $(WorkingDirectory)/vendor
restoreKeys: |
gems | "$(Agent.OS)"
gems
- task: Bash@3
displayName: Set deployment config
inputs:
workingDirectory: $(WorkingDirectory)
targetType: inline
script: bundle config set deployment true

- task: Bash@3
displayName: Install Gems
inputs:
workingDirectory: $(WorkingDirectory)
targetType: inline
script: bundle install

- task: Bash@3
displayName: Build
env:
TECH_DOCS_API_URL: https://dev.statistics.api.education.gov.uk
inputs:
workingDirectory: $(WorkingDirectory)
targetType: inline
script: |
bundle install
script: |
bundle exec middleman build
# Remove afterwards as we don't want it in the artifact
rm -rf build
- task: PublishPipelineArtifact@1
displayName: Publish artifact
displayName: Publish Public API docs artifact
inputs:
artifactName: public-api-docs
targetPath: $(WorkingDirectory)/build

targetPath: $(System.DefaultWorkingDirectory)/src/$(PublicApiDocsDir)

- job: MiscellaneousArtifacts
pool:
Expand Down
11 changes: 7 additions & 4 deletions infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,23 @@ jobs:
versionSpec: '>= $(rubyVersion)'

- task: Bash@3
displayName: Install Gems
displayName: Create middleman binary
inputs:
workingDirectory: $(docsPath)
targetType: inline
script: bundle install
script: bundle binstubs middleman-cli

- task: Bash@3
displayName: Build API docs
env:
TECH_DOCS_API_URL: $(publicApiUrl)
TECH_DOCS_API_URL: $(apiAppUrl)
TECH_DOCS_ALLOW_INDEXING: $(docsPreventIndexing)
inputs:
workingDirectory: $(docsPath)
targetType: inline
script: bundle exec middleman build
script: |
chmod -R 755 vendor
./bin/middleman build
- task: AzureCLI@2
displayName: Get deployment token
Expand Down
1 change: 1 addition & 0 deletions src/explore-education-statistics-api-docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Ignore cache
/.sass-cache
/.cache
/vendor

# Ignore .DS_store file
.DS_Store
Expand Down
3 changes: 2 additions & 1 deletion src/explore-education-statistics-api-docs/config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'dotenv'
require 'govuk_tech_docs'
require 'lib/utils/env'
require 'lib/api_reference_pages_extension'
require 'lib/helpers'
require 'lib/api_reference_helpers'
Expand All @@ -19,7 +20,7 @@
end

if ENV.has_key?("TECH_DOCS_PREVENT_INDEXING")
config[:tech_docs][:prevent_indexing] = ENV["TECH_DOCS_PREVENT_INDEXING"]
config[:tech_docs][:prevent_indexing] = EnvUtils.get_bool("TECH_DOCS_PREVENT_INDEXING")
end

if ENV.has_key?("TECH_DOCS_API_URL")
Expand Down
13 changes: 13 additions & 0 deletions src/explore-education-statistics-api-docs/lib/utils/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class EnvUtils

# @param [String] key
# @return [Boolean]
def self.get_bool(key)
case ENV[key]
when "false", "f", "no", "n", "0", ""
false
else
true
end
end
end

0 comments on commit 43befe7

Please sign in to comment.