# In case something goes horribly wrong, you can fall back to `image: ruby:latest` image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.4 stages: - test - deploy - release # This will try to build the web site, and store the result in "build" directory build the web site: stage: test variables: JEKYLL_ENV: production artifacts: expire_in: 3 days paths: - build before_script: - bundle install script: - 'echo "baseurl: /$CI_PROJECT_NAME" >> _config_ci.yml' - 'echo "url: https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN" >> _config_ci.yml' - bundle exec jekyll build -d build --config "_config.yml,_config_ci.yml" # This will actually deploy the web site when pushing to master pages: stage: deploy rules: # Run only on branch named "latest" - if: $CI_COMMIT_BRANCH == "latest" script: - mv build public - echo "Your website is available at $CI_PAGES_URL" artifacts: expire_in: 3 days paths: - public # This will tag the repository when the version-file changes and the theme successfully builds auto-tag: stage: deploy image: alpine:3.1 only: changes: - "lib/jekyll-theme-lcsb-default.rb" before_script: - 'which ssh-agent || ( apk add --update openssh )' - apk add --update git - eval $(ssh-agent -s) - echo "$SSHPRIVKEY" | tr -d '\r' | ssh-add - > /dev/null - mkdir -p ~/.ssh && chmod 700 ~/.ssh - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' - echo "$KNOWNHOSTS" > ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts variables: VERSION_FILE: "lib/jekyll-theme-lcsb-default.rb" REPOSITORY: "ssh://git@git-r3lab-server.uni.lu:8022/core-services/jekyll-theme-lcsb-default.git" TARGET_BRANCH: latest script: # Make sure that it is on latest, otherwise exit. THIS IS A WORKAROUND, AS HAVING BOTH ONLY AND RULES IS NOT POSSIBLE - '[[ "${CI_COMMIT_BRANCH:-1}" == "$TARGET_BRANCH" ]] && echo "On correct branch ($CI_COMMIT_BRANCH)" || exit 0' # Set correct git user and email - git config user.name $GIT_USER - git config user.email $GIT_EMAIL # Make sure that the version exists and is correct, and put it in envvar - cat $VERSION_FILE | grep "VERSION" | tr -d A-z\"\= | tr -d ' ' - VERSION=`cat $VERSION_FILE | grep "VERSION" | tr -d A-z\"\= | tr -d ' '` - '[[ -z $VERSION ]] && exit -1 || echo "OK, version appears to be correct -> $VERSION"' # Create the tag - git tag -a $VERSION -m $VERSION # Add SSH remote for accessing the repository - git remote add upstream $REPOSITORY # Publish the tag - git push upstream $VERSION # This will push the gem to ruby-gems when the repository has been tagged release: stage: release script: - mkdir -p ~/.gem && echo "$API_KEY_BASE64" | base64 --decode > ~/.gem/credentials && chmod 0600 ~/.gem/credentials - gem build jekyll-theme-lcsb-default.gemspec && gem push jekyll-theme-lcsb-default*.gem rules: # Run only when there is a new tag - if: $CI_COMMIT_TAG