-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
73 lines (69 loc) · 2.44 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
stages:
- check
- build
- deploy
pre-commit:
stage: check
image: python:3
before_script:
- pip install "virtualenv<v20.24.6" # temporary fix for gitlint
- pip install "pre-commit==3.6.0"
script:
- TMP_MSG_FILE="$(mktemp)"
- git log -1 --pretty=%B > "${TMP_MSG_FILE}"
- pre-commit run
--all-files
--color=always
--show-diff-on-failure
--hook-stage commit &&
pre-commit run
--all-files
--color=always
--show-diff-on-failure
--hook-stage commit-msg
--commit-msg-filename "${TMP_MSG_FILE}" ||
{
>&2 echo "pre-commit checks failed. Please consider installing pre-commit";
>&2 echo "hooks in your local Git clone by running \`make git-hooks-install\`.";
exit 1;
}
build-image:
stage: build
image: docker:stable
script:
- docker build -t "${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}" .
- docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}"
- docker push "${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}"
only:
- master@Scientific-IT-Systems/administration/mail_relay
- tags@Scientific-IT-Systems/administration/mail_relay
deploy-to-dockerhub:
stage: deploy
image: docker:stable
script:
- docker login -u gitlab-ci-token -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}"
- docker pull "${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}"
- docker tag
"${CI_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}"
"${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}"
- docker login -u "${DOCKERHUB_USER}" -p "${DOCKERHUB_SECRET}"
- docker push "${DOCKERHUB_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_TAG:-latest}"
only:
- master@Scientific-IT-Systems/administration/mail_relay
- tags@Scientific-IT-Systems/administration/mail_relay
deploy-to-github:
stage: deploy
image: iffregistry.fz-juelich.de/docker-images/gr-build-images/deploy
variables:
GIT_STRATEGY: none
only:
- master@Scientific-IT-Systems/administration/mail_relay
- tags@Scientific-IT-Systems/administration/mail_relay
script:
- mkdir --mode=700 ~/.ssh/
- (umask 0377 && echo "${GITHUB_DEPLOY_KEY}" > ~/.ssh/id_rsa
&& echo "github.com ${GITHUB_HOST_KEY}" >> ~/.ssh/known_hosts)
- git clone --mirror "${CI_REPOSITORY_URL}" "${CI_PROJECT_NAME}_mirror"
- cd "${CI_PROJECT_NAME}_mirror";
git push --mirror "git@github.com:sciapp/${CI_PROJECT_NAME}.git";
cd ..