Created
April 2, 2020 08:23
-
-
Save Ex-Ark/70188687d109d6aa42e74f47d17c06a9 to your computer and use it in GitHub Desktop.
Gitlab CI config for testing, building static swagger documentation and deploying doc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- documentation | |
- deploy | |
rspec: | |
stage: test | |
# Cache gems in between builds | |
cache: | |
paths: | |
- vendor/bundle | |
image: "ruby:2.5.7" | |
services: | |
- mysql:5.7 | |
variables: | |
MYSQL_DATABASE: my_db | |
MYSQL_ROOT_PASSWORD: for_test_only | |
BUNDLE_PATH: vendor/bundle | |
before_script: | |
- apt-get update -qq && apt-get install -y -qq mariadb-server mariadb-client libmariadbclient-dev | |
- gem install bundler | |
- RAILS_ENV=test bundle check || bundle install --jobs $(nproc) | |
- cp config/database.yml.gitlab config/database.yml | |
- cp config/secrets.yml.example config/secrets.yml | |
- RAILS_ENV=test bundle exec rake db:create db:schema:load | |
script: | |
- RAILS_ENV=test bundle exec rspec | |
- RAILS_ENV=test bundle exec rake doc | |
artifacts: | |
paths: | |
- swagger/swagger.json | |
generate_doc: | |
stage: documentation | |
image: | |
name: "swaggerapi/swagger-codegen-cli:2.4.10" | |
entrypoint: [""] | |
script: | |
- /usr/bin/java -jar /opt/swagger-codegen-cli/swagger-codegen-cli.jar generate -i ./swagger/swagger.json -l html2 | |
artifacts: | |
paths: | |
- index.html | |
deploy_doc: | |
image: "alpine" | |
stage: deploy | |
before_script: | |
- apk add openssh-client sshpass | |
- export SSHPASS="$SSH_USER_PASS" | |
script: | |
- sshpass -e scp -q -o stricthostkeychecking=no index.html $SSH_USER@$SSH_HOST:www/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
swagger.json
on stagerspec
directly from specshtml
documentationdeploy_doc
stage pushes the html file to awww/
public html directory, in order to make it available