Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.56 KiB
stages:

  - lint
  - build
  - upload
  - release

lint-job:
  stage: lint
  image:
    name: stoplight/spectral:latest
    entrypoint: [ "" ]
  script:
    - spectral lint spec/*.yml

build:
  stage: build
  image: node:current-alpine
  before_script:
    - npm install -g @apidevtools/swagger-cli
    - mkdir dist
  script: swagger-cli bundle -t yaml -o dist/combined.yml spec/combined.yml
  # find ./spec -type f -name "*.yml" -exec sh -c 'swagger-cli bundle -t yaml -o dist/$(basename {}) {}' \;
  artifacts:
    expose_as: 'Built API spec'
    paths:
      - dist/
    expire_in: 30 days

upload:
  stage: upload
  image: alpine:latest
  only:
    refs:
      - master
      - tags
    variables:
      - $CI_COMMIT_TAG
  before_script:
    - apk add rsync openssh-client
    - eval $(ssh-agent -s)
    - echo "$CI_DEPLOYMENT_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
  script: >
    rsync -rLvz --size-only --checksum --ipv4 --progress ./dist/. --temp-dir=~/tmp/ fitko@dorado.uberspace.de:html/$CI_COMMIT_TAG/

release-new-api-version:
  stage: release
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  needs:
    - job: build
      artifacts: true
  only:
    refs:
      - master
      - tags
    variables:
      - $CI_COMMIT_TAG
  script:
    - release-cli -v
    - echo "Releasing new API version"
    - release-cli create --name "v$CI_COMMIT_TAG" --description './CHANGELOG.md'
      --tag-name $CI_COMMIT_TAG
      --assets-link '{"name":"combined-$CI_COMMIT_TAG","url":"https://fitko.uber.space/$CI_COMMIT_TAG/combined.yml"}'