forked from DOMjudge/domjudge-packaging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
151 lines (135 loc) · 3.58 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
include: '.tarball-release.yml'
image: docker:latest
stages:
- test
- deploy
variables:
GITLABCI_VERSION: "2.1"
GITLABCI_IMAGE: "gitlabci"
CONTRIBUTOR_IMAGE: "domjudge/domjudge-contributor"
DOMJUDGE_VERSION:
value: "M.m.pp"
description: "The DOMjudge version, Change this variable to 7.3.3 to release the 7.3.3 dockers. The file should be available on the domjudge.org webserver."
DOMJUDGE_LATEST:
value: "true"
description: "Whether this is the latest release"
# Docker Login steps
.release_template: &release_docker
services:
- docker:dind
.registry_template: ®istry_gitlab
<<: *release_docker
stage: test
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
.registry_template: ®istry_dockerhub
<<: *release_docker
stage: deploy
before_script:
- docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_ACCESS_TOKEN
.job_template: &job_check-pr
stage: test
services:
- docker:dind
except:
- main
.matrix_contributor_template: &matrix_contributor_template
parallel:
matrix:
- ARCH: [amd64, arm64v8]
.job_template: &ci_template
script:
- cd docker-gitlabci
- >
if [[ -z $DOCKER_HUB_USERNAME ]]; then
BASE=$CI_REGISTRY_IMAGE/$GITLABCI_IMAGE
else
BASE="domjudge/"$GITLABCI_IMAGE
fi
- sh ./build.sh $GITLABCI_VERSION $BASE
- docker push $BASE:$GITLABCI_VERSION
pr-ci:
<<: *registry_gitlab
<<: *ci_template
only:
changes:
- .gitlab-ci.yml
- docker-gitlabci/**/*
except:
- main
release-ci:
<<: *registry_dockerhub
<<: *ci_template
only:
refs:
- main
changes:
- .gitlab-ci.yml
- docker-gitlabci/**/*
check-pr-contributor:
<<: *job_check-pr
<<: *matrix_contributor_template
only:
changes:
- .gitlab-ci.yml
- docker-contributor/**/*
script:
- cd docker-contributor
- docker pull $CONTRIBUTOR_IMAGE:${ARCH} || true
- docker build --build-arg ARCH=${ARCH}/ .
release-contributor-arch:
<<: *registry_dockerhub
<<: *matrix_contributor_template
only:
refs:
- main
changes:
- .gitlab-ci.yml
- docker-contributor/**/*
script:
- cd docker-contributor
- docker pull $CONTRIBUTOR_IMAGE:${ARCH} || true
- docker build -t $CONTRIBUTOR_IMAGE:${ARCH} --build-arg ARCH=${ARCH}/ .
- docker push $CONTRIBUTOR_IMAGE:${ARCH}
release-contributor-latest:
<<: *registry_dockerhub
only:
refs:
- main
changes:
- .gitlab-ci.yml
- docker-contributor/**/*
needs:
- release-contributor-arch
script:
- docker manifest create $CONTRIBUTOR_IMAGE:latest -a $CONTRIBUTOR_IMAGE:amd64 -a $CONTRIBUTOR_IMAGE:arm64v8
- docker manifest push $CONTRIBUTOR_IMAGE:latest
release-DOMjudge:
<<: *registry_dockerhub
when: manual
allow_failure: false
only:
- main
script:
- cd docker
- sh ./build.sh $DOMJUDGE_VERSION
- >
for IMG in domserver judgehost default-judgehost-chroot; do
docker push domjudge/$IMG:$DOMJUDGE_VERSION
if [ ${DOMJUDGE_LATEST} == "true" ]; then
docker tag domjudge/$IMG:$DOMJUDGE_VERSION domjudge/$IMG:latest
docker push domjudge/$IMG:latest
fi
done
check-pr-DOMjudge:
<<: *job_check-pr
only:
changes:
- .gitlab-ci.yml
- docker/**/*
script:
- HUBURL="https://registry.hub.docker.com/v1/repositories/domjudge/domserver/tags"
- apk add jq curl
- TAG=$(curl "$HUBURL" | jq -r '.[].name' |sort|tail -n2|head -n1)
- cd docker
- sh ./build.sh $TAG