.gitlab-ci.yml 3.19 KB
Newer Older
1 2 3
# https://docs.gitlab.com/ee/ci/yaml/README.html
# Links for more info at end of file

4
variables:
5 6 7

  # Disable the default Git behavior [2]. We want to define our own Git commands
  # (in the `before_script` section) to make this process faster.
8
  GIT_STRATEGY: none
9 10 11

  # We only need the last commit, not the whole history, so we set this [3] for
  # shallow fetch [4].
12
  GIT_DEPTH: "1"
13 14 15 16

  # This repository has Git LFS [5] enabled for some binary file types
  # (see .gitattributes file), so we set this to temporarily skip those LFS
  # files. This gives us faster parallel batch download [6].
17
  GIT_LFS_SKIP_SMUDGE: "1"
18

19 20 21 22 23 24 25 26 27 28 29 30
default:
  # Run CI in an environment (a Docker image [1]) with Ruby, the language needed
  # to run specscript.rb (more info on this file below).
  image: ruby:alpine
  tags:
    - gitlab-org

workflow:
  rules:
    # For `master` branch, create a pipeline (this includes on schedules, pushes, merges, etc.).
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

31 32 33
# This is a special job name that tells CI to pass the output to GitLab Pages
# so it can be used to serve your website. If we use another name, GitLab
# Pages does not work. [7]
34
pages:
35 36 37 38

  # Run Git commands to get the contents of the last commit (`$CI_COMMIT_SHA` [8],
  # the commit that triggered the CI) from the current repository
  # (`$CI_REPOSITORY_URL` [8]).
39 40
  before_script:
    - "apk add -U --no-cache git git-lfs"
41 42 43 44
    - "git init"
    - "git remote add origin $CI_REPOSITORY_URL"
    - "git fetch --depth $GIT_DEPTH origin $CI_COMMIT_SHA"
    - "git checkout FETCH_HEAD"
45
  script:
46 47 48 49

    # Get the previously skipped LFS files from the `hosted/` folder. As the
    # name implies, this is where we save the design specs, prototypes, and
    # HTML pages that we intend to host.
50
    - "git lfs pull -I 'hosted/'"
51 52 53 54

    # Run the Ruby script. It moves all files and folders from `hosted/` to
    # `public/` and creates an `index.html` file with a list of links to all of
    # the HTML pages contained within.
55
    - "ruby specscript.rb"
56 57 58 59 60

  # Set the `public/` folder as the result of the job, which is picked up by
  # GitLab Pages. The artifacts (files and folders being hosted) will be sent
  # to GitLab after the job finishes successfully and will be available for
  # download via the GitLab UI for 1 week. [9]
61 62
  artifacts:
    paths:
63
      - public
64
    expire_in: 1 week
65

66 67 68 69 70
  # Only run this job when changes are made to files or subdirectories in the
  # `hosted/` folder. [10]
  rules:
    - changes:
        - hosted/**/*
71

72 73 74 75 76 77 78 79 80 81

# [1]: https://docs.gitlab.com/ee/ci/docker/using_docker_images.html
# [2]: https://docs.gitlab.com/ee/ci/yaml/README.html#git-strategy
# [3]: https://docs.gitlab.com/ee/ci/yaml/README.html#shallow-cloning
# [4]: https://git-scm.com/docs/git-fetch#git-fetch---depthltdepthgt
# [5]: https://docs.gitlab.com/ee/workflow/lfs/manage_large_binaries_with_git_lfs.html
# [6]: https://github.com/git-lfs/git-lfs/wiki/Tutorial#pulling-and-cloning
# [7]: https://docs.gitlab.com/ee/ci/yaml/README.html#pages
# [8]: https://docs.gitlab.com/ee/ci/variables/README.html#predefined-variables-environment-variables
# [9]: https://docs.gitlab.com/ee/ci/yaml/README.html#artifacts
82
# [10]: https://docs.gitlab.com/ee/ci/yaml/README.html#onlyexcept-basic