summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/templates/Pages/SwaggerUI.gitlab-ci.yml
blob: 961941ac4d0eceb4fd859c08c4a642158e87feeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# To contribute improvements to CI/CD templates, please follow the Development guide at:
# https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Pages/SwaggerUI.gitlab-ci.yml

image: node:10-alpine

# specify the location of the Open API Specification files within your project
# and the filename of the specification that you would like to display by default
variables:
  DOCS_FOLDER: "api-docs"
  SPEC_TO_DISPLAY: "my-project_specification_0.0.1.json"

# These folders are cached between builds
cache:
  paths:
    - ./node_modules

# publishes all files from the $DOCS_FOLDER together with the static version of SwaggerUI
# sets the specification file named in $SPEC_TO_DISPLAY to be displayed by default
pages:
  stage: deploy
  before_script:
    - npm install swagger-ui-dist@3.22.1
  script:
    - mkdir public
    - cp -rp node_modules/swagger-ui-dist/* public
    - cp -rp $DOCS_FOLDER/* public
    - sed -i "s#https://petstore\.swagger\.io/v2/swagger\.json#$SPEC_TO_DISPLAY#g" public/index.html
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH