CV/.gitlab/ci/cv-gitlab-ci.yml
Dan Anglin ef50b88032
ci: workflow and rules
This commit brings the CI pipeline configuration up to date.

Changes include:

- add workflow rules.
- remove only/except syntax in favourof rules.
- update ref to CV builder image.
- add Dockerfile linting as part of the test stage.
- fix linting issues in Dockerfile.
2020-08-08 04:36:13 +01:00

69 lines
1.5 KiB
YAML

---
.use-cv-builder:
image: ${IMAGE_NAME}:master-cb8a29c7
.test-conditions:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- if:
changes:
- docker/Dockerfile
- __output/*
when: never
.publish-conditions:
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PROJECT_PATH == "dananglin/cv"'
when: always
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
- if:
changes:
- docker/Dockerfile
- __output/*
when: never
test:spellcheck:
before_script:
- apt-get update
- apt-get -y install aspell make
extends:
- .test-conditions
image: ubuntu:18.04
stage: test
script:
- make spellcheck
test:pdf:
artifacts:
expire_in: 1 hour
paths:
- __output/cv.pdf
extends:
- .use-cv-builder
- .test-conditions
stage: test
script:
- make clean pdf
publish:pdf:
extends:
- .use-cv-builder
- .publish-conditions
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 clean pdf
- git checkout master
- git add __output/cv.pdf
- 'git commit -m "auto: update CV."'
- git push origin master