Instantly share code, notes, and snippets.

Embed
What would you like to do?
GitLab CI
cache:
# Use a cache for every branch and every stage
key: "$CI_COMMIT_REF_NAME/$CI_JOB_STAGE"
# Cache the path .cache within the project workspace
paths:
- .cache/
variables:
# Tell composer to save and load it's cache within the .cache folder
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer"
.dedicated-runner: &dedicated-runner
# Just use runner that are taged with docker AND linux
tags:
- docker
- linux
.deploy: &deploy
<<: *dedicated-runner
# Use a prepared docker image that contains surf, node and global gulp
image: t3easy/surf:gulp
stage: deploy
before_script:
# Start ssh-agent
- eval $(ssh-agent -s)
# Add the ssh private key to the agent
- bash -c "ssh-add <(echo \"$SSH_PRIVATE_KEY\")"
# Only trust the hosts you already know
- 'mkdir -p ~/.ssh && [[ -f /.dockerenv ]] && echo $KNOWN_HOSTS > ~/.ssh/known_hosts'
- surf --version
deploy:staging:
<<: *deploy
only:
- develop
script:
# Go surf, go!
- surf deploy staging.mysite.tld
deploy:live:
<<: *deploy
only:
- master
script:
# Go surf, go!
- surf deploy www.mysite.tld

GitLab CI

Examples:

https://github.com/georgringer/news/blob/master/.gitlab-ci.yml https://gist.github.com/spoonerWeb/53ea8a4bdc6fbb92a74195aba7339e94

Doc

https://docs.gitlab.com/ce/ci/README.html

To speed up and for reliability

  • Use (own) docker images for the jobs that have all tools you need for your build already installed. Your before_script should shrink to a minimum
  • Use the GitLab CI cache but don't depend on them!! https://docs.gitlab.com/ce/ci/yaml/README.html#cache "The cache is provided on a best-effort basis, so don't expect that the cache will be always present."
  • "You can only use paths that are within the project workspace."
  • Cache the caches! Configure the tools to use folders within the project workspace and save that folder to the GitLab CI Cache
  • Tag your runners
  • Define a cache key that fits to your jobs. Don't override your good, filled cache!
  • Use job templates and variables
@t3easy

This comment has been minimized.

Owner

t3easy commented Jun 22, 2017

Please write a comment if you liked or disliked the talk and give me some feedback what I can clarify!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment