-
Jonas Gröger authoredJonas Gröger authored
.gitlab-ci.yml 3.33 KiB
.ssh-setup: &ssh-setup
- eval $(ssh-agent -s)
- echo "$CI_DEPLOYMENT_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- echo "$UBERSPACE_KNOWN_HOST" >> ~/.ssh/known_hosts
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_COMMIT_TAG'
stages:
- build
- lint
- upload
- validate
build:
stage: build
image: ${CI_REGISTRY}/fit-connect/baseimage:latest
before_script:
- npm install -g @apidevtools/swagger-cli
- mkdir dist
script:
- swagger-cli bundle --type yaml --outfile dist/submission-api.yaml spec/submission-api.yaml
artifacts:
expose_as: 'Built API spec'
paths:
- dist/
expire_in: 1 day
lint:
stage: lint
image:
name: $CI_REGISTRY/stoplight/spectral:5
entrypoint: [ "" ]
script:
- spectral lint spec/submission-api.yaml --verbose --display-only-failures
- spectral lint dist/submission-api.yaml --verbose --display-only-failures
upload:preview:
stage: upload
image: ${CI_REGISTRY}/fit-connect/baseimage:latest
environment:
name: review/$CI_COMMIT_REF_NAME
on_stop: stop:preview
auto_stop_in: 2 week
url: https://preview.docs.fitko.dev/submission-api/$CI_COMMIT_REF_SLUG/
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
before_script:
- *ssh-setup
script:
- rsync -Lvz -e "ssh -o CheckHostIP=no" ./ci/index.html fitko@dorado.uberspace.de:preview.docs.fitko.dev/submission-api/$CI_COMMIT_REF_SLUG/
- rsync -Lvz -e "ssh -o CheckHostIP=no" ./ci/rapidoc.js fitko@dorado.uberspace.de:preview.docs.fitko.dev/submission-api/$CI_COMMIT_REF_SLUG/
- rsync -Lvz -e "ssh -o CheckHostIP=no" ./dist/submission-api.yaml fitko@dorado.uberspace.de:preview.docs.fitko.dev/submission-api/$CI_COMMIT_REF_SLUG/
- rsync -Lvz -e "ssh -o CheckHostIP=no" ./dist/submission-api.yaml fitko@dorado.uberspace.de:schema.fitko.de/fit-connect/submission-api/latest-dev/
link-check:
stage: validate
variables:
CRAWLER_URL: "https://schema.fitko.de/fit-connect/submission-api/"
CRAWLER_DOMAIN: "schema.fitko.de"
CRAWL_ONE_DOMAIN_ONLY: "yes"
trigger:
strategy: depend
project: fit-connect/schema-link-checker
branch: main