Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
thomasDOTwtf
hub
Commits
4bd5498b
Commit
4bd5498b
authored
10 months ago
by
HeJ
Browse files
Options
Downloads
Plain Diff
Merge branch 'ci-rework' into 'develop'
Update production pipeline See merge request
!979
parents
5209fcd7
bc441787
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+71
-28
71 additions, 28 deletions
.gitlab-ci.yml
with
71 additions
and
28 deletions
.gitlab-ci.yml
+
71
−
28
View file @
4bd5498b
...
@@ -8,16 +8,19 @@ stages:
...
@@ -8,16 +8,19 @@ stages:
workflow
:
workflow
:
rules
:
rules
:
# Allow manual pipeline runs
-
if
:
$FORCE_PIPELINE_RUN == 'true'
-
if
:
$FORCE_PIPELINE_RUN == 'true'
# Tags with format "prod-yyyy-mm-dd_HH-MM" will be tagged as production and latest
-
if
:
$CI_COMMIT_TAG
-
if
:
$CI_COMMIT_TAG
-
if
:
$CI_PIPELINE_SOURCE == 'merge_request_event'
-
if
:
$CI_PIPELINE_SOURCE == 'merge_request_event'
-
if
:
($CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "production")
-
if
:
$CI_COMMIT_BRANCH == "develop"
# prevent duplicate pipeline runs for merge requests
-
if
:
$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
-
if
:
$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when
:
never
when
:
never
-
if
:
$CI_COMMIT_BRANCH
-
if
:
$CI_COMMIT_BRANCH
.default-rules
:
.default-rules
:
rules
:
rules
:
-
if
:
(
$CI_COMMIT_BRANCH == "develop"
|| $CI_COMMIT_BRANCH == "production")
-
if
:
$CI_COMMIT_BRANCH == "develop"
-
if
:
$CI_COMMIT_TAG
-
if
:
$CI_COMMIT_TAG
-
if
:
$CI_PIPELINE_SOURCE == 'merge_request_event'
-
if
:
$CI_PIPELINE_SOURCE == 'merge_request_event'
-
if
:
$FORCE_PIPELINE_RUN == 'true'
-
if
:
$FORCE_PIPELINE_RUN == 'true'
...
@@ -25,9 +28,13 @@ workflow:
...
@@ -25,9 +28,13 @@ workflow:
# Use build cache to speed up CI
# Use build cache to speed up CI
default
:
default
:
cache
:
cache
:
-
key
:
$CI_COMMIT_REF_SLUG
-
key
:
"
kaniko-default"
paths
:
-
.cache/kaniko
-
key
:
"
python-default"
paths
:
paths
:
-
.cache/pip
-
.cache/pip
-
.cache/pdm
-
key
:
-
key
:
files
:
files
:
-
src/plainui/yarn.lock
-
src/plainui/yarn.lock
...
@@ -49,6 +56,22 @@ default:
...
@@ -49,6 +56,22 @@ default:
SSO_SECRET_GENERATE
:
"
True"
SSO_SECRET_GENERATE
:
"
True"
STORAGE_TYPE
:
local
STORAGE_TYPE
:
local
# Warm up the local image cache
# Will throw a warning for local stages, but that's fine
warmup
:
stage
:
prepare
image
:
name
:
gcr.io/kaniko-project/executor:debug
entrypoint
:
[
"
"
]
cache
:
paths
:
-
"
$CI_PROJECT_DIR/.cache/kaniko"
script
:
-
/kaniko/warmer --cache-dir=$CI_PROJECT_DIR/.cache/kaniko -d Dockerfile
rules
:
-
when
:
always
# Kaniko build setup
# Kaniko build setup
.build
:
.build
:
image
:
image
:
...
@@ -86,10 +109,12 @@ generate_css:
...
@@ -86,10 +109,12 @@ generate_css:
meta_build
:
meta_build
:
stage
:
prepare
stage
:
prepare
extends
:
.build
extends
:
.build
needs
:
-
warmup
variables
:
variables
:
PIP_CACHE_DIR
:
"
$CI_PROJECT_DIR/.cache/pip"
PIP_CACHE_DIR
:
"
$CI_PROJECT_DIR/.cache/pip"
script
:
script
:
-
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/.meta/Dockerfile --destination $CI_REGISTRY_IMAGE/build_image:
latest
$KANIKO_ARGS $KANIKO_CACHE_ARGS
-
/kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/.meta/Dockerfile --destination $CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
$KANIKO_ARGS $KANIKO_CACHE_ARGS
rules
:
rules
:
-
when
:
always
-
when
:
always
...
@@ -97,7 +122,7 @@ app_version:
...
@@ -97,7 +122,7 @@ app_version:
extends
:
extends
:
-
.default-rules
-
.default-rules
-
.django_runner_settings
-
.django_runner_settings
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -115,7 +140,7 @@ app_version:
...
@@ -115,7 +140,7 @@ app_version:
-
when
:
always
-
when
:
always
code_style
:
code_style
:
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -127,7 +152,7 @@ code_style:
...
@@ -127,7 +152,7 @@ code_style:
-
when
:
always
-
when
:
always
ruff
:
ruff
:
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -139,7 +164,7 @@ ruff:
...
@@ -139,7 +164,7 @@ ruff:
-
when
:
always
-
when
:
always
ruff_format
:
ruff_format
:
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -154,7 +179,7 @@ migration_check:
...
@@ -154,7 +179,7 @@ migration_check:
extends
:
extends
:
-
.default-rules
-
.default-rules
-
.django_runner_settings
-
.django_runner_settings
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -172,7 +197,7 @@ sanity_check:
...
@@ -172,7 +197,7 @@ sanity_check:
extends
:
extends
:
-
.default-rules
-
.default-rules
-
.django_runner_settings
-
.django_runner_settings
image
:
$CI_REGISTRY_IMAGE/build_image:
latest
image
:
$CI_REGISTRY_IMAGE/build_image:
$CI_PIPELINE_ID
stage
:
test
stage
:
test
needs
:
needs
:
-
meta_build
-
meta_build
...
@@ -353,42 +378,60 @@ test_nginx_static:
...
@@ -353,42 +378,60 @@ test_nginx_static:
-
crane delete $CI_REGISTRY_IMAGE/ci/hub:ci-${CI_PIPELINE_ID}
-
crane delete $CI_REGISTRY_IMAGE/ci/hub:ci-${CI_PIPELINE_ID}
-
crane delete $CI_REGISTRY_IMAGE/ci/nginx:ci-${CI_PIPELINE_ID}
-
crane delete $CI_REGISTRY_IMAGE/ci/nginx:ci-${CI_PIPELINE_ID}
publish
:
publish
-commit
:
extends
:
extends
:
-
.publish-clean
-
.publish-clean
script
:
script
:
-
crane
copy
$CI_REGISTRY_IMAGE/ci/hub:ci-${CI_PIPELINE_ID} $
CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
-
crane
tag
$CI_REGISTRY_IMAGE/ci/hub:ci-${CI_PIPELINE_ID} $
{CI_COMMIT_SHORT_SHA}
-
crane
copy
$CI_REGISTRY_IMAGE/ci/nginx:ci-${CI_PIPELINE_ID} $
CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_NAME
-
crane
tag
$CI_REGISTRY_IMAGE/ci/nginx:ci-${CI_PIPELINE_ID} $
{CI_COMMIT_SHORT_SHA}
rules
:
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
"develop"
||
$CI_
COMMIT_BRANCH
==
"production"
'
-
if
:
'
$CI_COMMIT_BRANCH
==
"develop"
||
$CI_
PIPELINE_SOURCE
==
"merge_request_event"
||
$CI_COMMIT_TAG
'
-
when
:
never
-
when
:
never
publish_latest
:
publish-mr
:
extends
:
-
.publish-image
needs
:
needs
:
-
publish
-
publish-commit
script
:
-
crane tag $CI_REGISTRY_IMAGE/ci/hub:${CI_COMMIT_SHORT_SHA} mr-${CI_MERGE_REQUEST_ID}
-
crane tag $CI_REGISTRY_IMAGE/ci/nginx:${CI_COMMIT_SHORT_SHA} mr-${CI_MERGE_REQUEST_ID}
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"merge_request_event"'
-
when
:
never
publish-develop
:
extends
:
extends
:
-
.publish-image
-
.publish-image
needs
:
-
publish-commit
script
:
script
:
-
crane
tag
$CI_REGISTRY_IMAGE:$CI_COMMIT_
REF_NAME lates
t
-
crane
copy
$CI_REGISTRY_IMAGE
/ci/hub
:$
{
CI_COMMIT_
SHORT_SHA} $CI_REGISTRY_IMAGE:developmen
t
-
crane
tag
$CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_
REF_NAME lates
t
-
crane
copy
$CI_REGISTRY_IMAGE/
ci/
nginx:$
{
CI_COMMIT_
SHORT_SHA} $CI_REGISTRY_IMAGE/nginx:developmen
t
rules
:
rules
:
-
if
:
'
$CI_COMMIT_BRANCH
==
"production"
'
-
if
:
$CI_COMMIT_BRANCH ==
'develop
'
-
when
:
never
-
when
:
never
publish_merge_requests
:
# Publish to production and add latest tag
publish-production
:
extends
:
extends
:
-
.publish-clean
-
.publish-image
needs
:
-
publish-commit
script
:
script
:
-
crane tag $CI_REGISTRY_IMAGE/ci/hub:ci-${CI_PIPELINE_ID} mr-$CI_MERGE_REQUEST_ID
-
crane copy $CI_REGISTRY_IMAGE/ci/hub:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:production
-
crane tag $CI_REGISTRY_IMAGE/ci/nginx:ci-${CI_PIPELINE_ID} mr-$CI_MERGE_REQUEST_ID
-
crane tag $CI_REGISTRY_IMAGE:production latest
-
crane copy $CI_REGISTRY_IMAGE/ci/nginx:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/nginx:production
-
crane tag $CI_REGISTRY_IMAGE/nginx:production latest
rules
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == 'merge_request_event'
-
if
:
'
$CI_COMMIT_TAG
=~
/^prod-\d{4}-\d{2}-\d{2}_\d{2}-\d{2}$/'
-
when
:
never
deploy_develop
:
deploy_develop
:
stage
:
deploy
stage
:
deploy
allow_failure
:
true
allow_failure
:
true
needs
:
needs
:
-
publish
-
publish
-develop
image
:
python:3.11-bookworm
image
:
python:3.11-bookworm
script
:
script
:
-
'
curl
-X
POST
"$DEPLOYMENT_SERVICEWEBHOOK_URL_DEVELOP"'
-
'
curl
-X
POST
"$DEPLOYMENT_SERVICEWEBHOOK_URL_DEVELOP"'
...
@@ -412,7 +455,7 @@ deploy_production:
...
@@ -412,7 +455,7 @@ deploy_production:
stage
:
deploy
stage
:
deploy
allow_failure
:
true
allow_failure
:
true
needs
:
needs
:
-
publish
-
publish
-production
image
:
python:3.11-bookworm
image
:
python:3.11-bookworm
script
:
script
:
-
'
curl
-X
POST
"$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION"'
-
'
curl
-X
POST
"$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION"'
...
@@ -425,8 +468,8 @@ deploy_production:
...
@@ -425,8 +468,8 @@ deploy_production:
-
if
:
'
$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION
==
null
||
$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION
==
""'
-
if
:
'
$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION
==
null
||
$DEPLOYMENT_SERVICEWEBHOOK_URL_PRODUCTION
==
""'
when
:
never
when
:
never
# only attempt to deploy on correct
branch
# only attempt to deploy on correct
tag
-
if
:
'
$CI_COMMIT_
BRANCH
==
"production"
'
-
if
:
'
$CI_COMMIT_
TAG
=~
/^prod-\d{4}-\d{2}-\d{2}_\d{2}-\d{2}$/
'
when
:
on_success
when
:
on_success
# otherwise, skip this
# otherwise, skip this
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment