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:
Dan Anglin 2019-12-22 02:53:11 +00:00
parent 5fbdaa5a02
commit b75a5c1eea
No known key found for this signature in database
GPG key ID: 7AC2B18EC1D09F27
4 changed files with 79 additions and 39 deletions

3
.gitignore vendored
View file

@ -1,3 +1,4 @@
__output/
__output/*
!__output/cv.pdf
tags
notes.txt

View file

@ -1,47 +1,12 @@
---
stages:
- test
- build
- publish
variables:
IMAGE_NAME: ${CI_REGISTRY}/${CI_PROJECT_PATH}/cv-builder
IMAGE_TAG: ${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}
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: .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
include:
- local: '/.gitlab/ci/docker-gitlab-ci.yml'
- local: '/.gitlab/ci/cv-gitlab-ci.yml'

View 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/*

View 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