Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
0e7f0f3e
Verified
Commit
0e7f0f3e
authored
1 year ago
by
Yoann Schneider
Browse files
Options
Downloads
Patches
Plain Diff
Publish during CI
parent
3d82612a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!442
Publish during CI
Pipeline
#142154
passed
1 year ago
Stage: test
Stage: build
Stage: release
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
worker-{{cookiecutter.slug}}/.gitlab-ci.yml
+32
-2
32 additions, 2 deletions
worker-{{cookiecutter.slug}}/.gitlab-ci.yml
worker-{{cookiecutter.slug}}/ci/build.sh
+6
-16
6 additions, 16 deletions
worker-{{cookiecutter.slug}}/ci/build.sh
with
38 additions
and
18 deletions
worker-{{cookiecutter.slug}}/.gitlab-ci.yml
+
32
−
2
View file @
0e7f0f3e
...
...
@@ -58,8 +58,15 @@ docker-build:
DOCKER_DRIVER
:
overlay2
DOCKER_HOST
:
tcp://docker:2375/
except
:
-
schedules
rules
:
# Never run on scheduled pipelines
-
if
:
'
$CI_PIPELINE_SOURCE
==
"schedule"'
when
:
never
# Use commit tag when running on tagged commit
-
if
:
$CI_COMMIT_TAG
variables
:
VERSION
:
$CI_COMMIT_TAG
-
when
:
on_success
script
:
-
ci/build.sh
...
...
@@ -83,3 +90,26 @@ bump-python-deps:
script
:
-
devops python-deps requirements.txt
publish-worker
:
stage
:
release
image
:
registry.gitlab.teklia.com/arkindex/cli:latest
script
:
-
arkindex -p "$ARKINDEX_INSTANCE" --gitlab-secure-file arkindex-cli.yaml worker publish "$CI_REGISTRY_IMAGE:$VERSION"
rules
:
# Never run on scheduled pipelines
-
if
:
'
$CI_PIPELINE_SOURCE
==
"schedule"'
when
:
never
# Use commit tag when running on tagged commit
-
if
:
$CI_COMMIT_TAG
variables
:
VERSION
:
$CI_COMMIT_TAG
-
when
:
on_success
parallel
:
matrix
:
-
ARKINDEX_INSTANCE
:
# Publish worker on https://demo.arkindex.org
-
demo
This diff is collapsed.
Click to expand it.
worker-{{cookiecutter.slug}}/ci/build.sh
+
6
−
16
View file @
0e7f0f3e
#!/bin/sh -e
# Build the tasks Docker image.
# Requires CI_PROJECT_DIR and CI_REGISTRY_IMAGE to be set.
# VERSION defaults to latest.
# Will automatically login to a registry if CI_REGISTRY, CI_REGISTRY_USER and CI_REGISTRY_PASSWORD are set.
# Will only push an image if $CI_REGISTRY is set.
if
[
-z
"
$VERSION
"
]
;
then
VERSION
=
${
CI_COMMIT_TAG
:-
latest
}
fi
if
[
-z
"
$VERSION
"
-o
-z
"
$CI_PROJECT_DIR
"
-o
-z
"
$CI_REGISTRY_IMAGE
"
]
;
then
echo
Missing environment variables
exit
1
echo
Missing environment variables
exit
1
fi
IMAGE_TAG
=
"
$CI_REGISTRY_IMAGE
:
$VERSION
"
...
...
@@ -19,14 +14,9 @@ IMAGE_TAG="$CI_REGISTRY_IMAGE:$VERSION"
cd
$CI_PROJECT_DIR
docker build
-f
Dockerfile
.
-t
"
$IMAGE_TAG
"
# Publish the image on the main branch or on a tag
if
[
"
$CI_COMMIT_REF_NAME
"
=
"
$CI_DEFAULT_BRANCH
"
-o
-n
"
$CI_COMMIT_TAG
"
]
;
then
if
[
-n
"
$CI_REGISTRY
"
-a
-n
"
$CI_REGISTRY_USER
"
-a
-n
"
$CI_REGISTRY_PASSWORD
"
]
;
then
echo
$CI_REGISTRY_PASSWORD
| docker login
-u
$CI_REGISTRY_USER
--password-stdin
$CI_REGISTRY
docker push
$IMAGE_TAG
else
echo
"Missing environment variables to log in to the container registry…"
fi
if
[
-n
"
$CI_REGISTRY
"
-a
-n
"
$CI_REGISTRY_USER
"
-a
-n
"
$CI_REGISTRY_PASSWORD
"
]
;
then
echo
$CI_REGISTRY_PASSWORD
| docker login
-u
$CI_REGISTRY_USER
--password-stdin
$CI_REGISTRY
docker push
$IMAGE_TAG
else
echo
"
The build was not published to the repository registry (only for main branch or tags)
…"
echo
"
Missing environment variables to log in to the container registry
…"
fi
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