ci: add pipeline for publishing CV.
The following changes are included in this commit: - add a pipeline for publishing the output CV to the master branch when a change has been committed to the master branch. - split the CI configuration into two files: one for the docker build pipeline and the other for the CV build pipeline.
This commit is contained in:
parent
5fbdaa5a02
commit
b75a5c1eea
4 changed files with 79 additions and 39 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
__output/
|
__output/*
|
||||||
|
!__output/cv.pdf
|
||||||
tags
|
tags
|
||||||
notes.txt
|
notes.txt
|
||||||
|
|
|
@ -1,47 +1,12 @@
|
||||||
---
|
---
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- build
|
|
||||||
- publish
|
- publish
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_PATH}/cv-builder
|
IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_PATH}/cv-builder
|
||||||
IMAGE_TAG: ${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}
|
IMAGE_TAG: ${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}
|
||||||
|
|
||||||
services:
|
include:
|
||||||
- docker:19.03.5-dind
|
- local: '/.gitlab/ci/docker-gitlab-ci.yml'
|
||||||
|
- local: '/.gitlab/ci/cv-gitlab-ci.yml'
|
||||||
.use-docker:
|
|
||||||
image: docker:19.03.5
|
|
||||||
|
|
||||||
.install-deps: &install-deps
|
|
||||||
- apk add --no-cache make
|
|
||||||
|
|
||||||
test:docker-image:
|
|
||||||
extends: .use-docker
|
|
||||||
script:
|
|
||||||
- *install-deps
|
|
||||||
- make image
|
|
||||||
stage: test
|
|
||||||
only:
|
|
||||||
changes:
|
|
||||||
- docker/Dockerfile
|
|
||||||
except:
|
|
||||||
refs:
|
|
||||||
- master
|
|
||||||
|
|
||||||
publish:docker-image:
|
|
||||||
extends: .use-docker
|
|
||||||
before_script:
|
|
||||||
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
|
|
||||||
after_script:
|
|
||||||
- docker logout ${CI_REGISTRY}
|
|
||||||
script:
|
|
||||||
- *install-deps
|
|
||||||
- make publish
|
|
||||||
stage: publish
|
|
||||||
only:
|
|
||||||
changes:
|
|
||||||
- docker/Dockerfile
|
|
||||||
refs:
|
|
||||||
- master@dananglin/cv
|
|
||||||
|
|
29
.gitlab/ci/cv-gitlab-ci.yml
Normal file
29
.gitlab/ci/cv-gitlab-ci.yml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
.use-cv-builder:
|
||||||
|
image: ${IMAGE_NAME}:master-5fbdaa5a
|
||||||
|
|
||||||
|
publish:cv:
|
||||||
|
extends: .use-cv-builder
|
||||||
|
before_script:
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||||
|
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
|
||||||
|
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
|
||||||
|
- chmod 0400 ~/.ssh/known_hosts
|
||||||
|
- git remote set-url origin git@gitlab.com:${CI_PROJECT_PATH}.git
|
||||||
|
- git config --global user.email "${GITLAB_USER_EMAIL}"
|
||||||
|
- git config --global user.name "${GITLAB_USER_NAME}"
|
||||||
|
stage: publish
|
||||||
|
script:
|
||||||
|
- make
|
||||||
|
- git checkout master
|
||||||
|
- git add __output/cv.pdf
|
||||||
|
- 'git commit -m "auto: update CV."'
|
||||||
|
- git push origin master
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- master@dananglin/cv
|
||||||
|
except:
|
||||||
|
changes:
|
||||||
|
- docker/Dockerfile
|
||||||
|
- __output/*
|
45
.gitlab/ci/docker-gitlab-ci.yml
Normal file
45
.gitlab/ci/docker-gitlab-ci.yml
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
---
|
||||||
|
.docker-dind-service:
|
||||||
|
services:
|
||||||
|
- docker:19.03.5-dind
|
||||||
|
|
||||||
|
.use-docker:
|
||||||
|
image: docker:19.03.5
|
||||||
|
|
||||||
|
.install-deps: &install-deps
|
||||||
|
- apk add --no-cache make
|
||||||
|
|
||||||
|
test:docker-image:
|
||||||
|
extends:
|
||||||
|
- .docker-dind-service
|
||||||
|
- .use-docker
|
||||||
|
script:
|
||||||
|
- *install-deps
|
||||||
|
- make image
|
||||||
|
stage: test
|
||||||
|
only:
|
||||||
|
refs:
|
||||||
|
- merge_requests
|
||||||
|
changes:
|
||||||
|
- docker/Dockerfile
|
||||||
|
except:
|
||||||
|
refs:
|
||||||
|
- master
|
||||||
|
|
||||||
|
publish:docker-image:
|
||||||
|
extends:
|
||||||
|
- .use-docker
|
||||||
|
- .docker-dind-service
|
||||||
|
before_script:
|
||||||
|
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
|
||||||
|
after_script:
|
||||||
|
- docker logout ${CI_REGISTRY}
|
||||||
|
script:
|
||||||
|
- *install-deps
|
||||||
|
- make publish
|
||||||
|
stage: publish
|
||||||
|
only:
|
||||||
|
changes:
|
||||||
|
- docker/Dockerfile
|
||||||
|
refs:
|
||||||
|
- master@dananglin/cv
|
Loading…
Reference in a new issue