diff --git a/azure-pipelines-main.yml b/azure-pipelines-main.yml index 1ee7ca5a90d..a10695aba71 100644 --- a/azure-pipelines-main.yml +++ b/azure-pipelines-main.yml @@ -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: @@ -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: @@ -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: diff --git a/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml b/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml index 05ccfac61d6..42da72afc53 100644 --- a/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml +++ b/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml @@ -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 diff --git a/src/explore-education-statistics-api-docs/.gitignore b/src/explore-education-statistics-api-docs/.gitignore index 771c4aca9cc..7b479f96e20 100644 --- a/src/explore-education-statistics-api-docs/.gitignore +++ b/src/explore-education-statistics-api-docs/.gitignore @@ -9,6 +9,7 @@ # Ignore cache /.sass-cache /.cache +/vendor # Ignore .DS_store file .DS_Store diff --git a/src/explore-education-statistics-api-docs/config.rb b/src/explore-education-statistics-api-docs/config.rb index a8c3f0fdd16..709f96569be 100644 --- a/src/explore-education-statistics-api-docs/config.rb +++ b/src/explore-education-statistics-api-docs/config.rb @@ -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' @@ -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") diff --git a/src/explore-education-statistics-api-docs/lib/utils/env.rb b/src/explore-education-statistics-api-docs/lib/utils/env.rb new file mode 100644 index 00000000000..f1c54f3ab6c --- /dev/null +++ b/src/explore-education-statistics-api-docs/lib/utils/env.rb @@ -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