Skip to content
Snippets Groups Projects
Commit 55c12b64 authored by Philippe Caseiro's avatar Philippe Caseiro
Browse files

Merge branch 'refactor/reusable-gitlab-ci-templates' into 'master'

ci(gitlab-ci): split in reusable templates

See merge request !5
parents ed58987d b39e36bd
No related branches found
No related tags found
No related merge requests found
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
###############################################################################
# Define stages and global variables
###############################################################################
default:
tags:
- one
- eole
- docker
include:
- local: templates/Rules.yaml
- local: templates/Runners/eole-docker.yaml
- local: templates/Lint/Commitlint.yaml
stages:
- lint
variables:
DOCKER_DRIVER: 'overlay2'
commitlint:
stage: lint
image: 'hub.eole.education/eole/commitlint:latest'
before_script:
# Add `upstream` remote to get access to `upstream/master`
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL}"
- 'git fetch --all'
after_script:
# Remove `upstream` to avoid caching `CI_JOB_TOKEN`
- "git remote remove upstream"
script:
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
commitlint:
stage: lint
extends: .default_rules
image: 'hub.eole.education/eole/commitlint:latest'
before_script:
# Add `upstream` remote to get access to `upstream/master`
- "git remote show upstream 2> /dev/null || git remote add upstream ${CI_REPOSITORY_URL}"
- 'git fetch --all'
after_script:
# Remove `upstream` to avoid caching `CI_JOB_TOKEN`
- "git remote remove upstream"
script:
# Set default commit hashes for `--from` and `--to`
- 'export COMMITLINT_FROM="$(git merge-base upstream/master HEAD)"'
- 'export COMMITLINT_TO="${CI_COMMIT_SHA}"'
# Run `commitlint`
- 'commitlint --from "${COMMITLINT_FROM}"
--to "${COMMITLINT_TO}"
--verbose'
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
###############################################################################
# Define rules templates to be used by jobs
###############################################################################
# Rules used by default
.default_rules:
rules:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
# All branches
- if: $CI_COMMIT_BRANCH
# Build on branches and release tag push
.build_rules:
rules:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
# All branches
- if: $CI_COMMIT_BRANCH
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
# Run semantic release only on $CI_DEFAULT_BRANCH except for release commits
.release_rules:
rules:
# Exclude $CI_DEFAULT_BRANCH of semantic-release commits
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_MESSAGE =~ /^chore\(release\):/
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Run on published release tags
.tag_rules:
rules:
# Only for protected release tags
- if: $CI_COMMIT_TAG =~ /^release\// && $CI_COMMIT_REF_PROTECTED
...
# -*- coding: utf-8 -*-
# vim: ft=yaml
---
default:
tags:
- one
- eole
- docker
...
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment