Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webservice
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
masi9606
webservice
Commits
a983b3d8
Commit
a983b3d8
authored
6 months ago
by
schnarkus
Browse files
Options
Downloads
Patches
Plain Diff
test
parent
087fca38
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#68718
passed
6 months ago
Stage: test
Stage: build
Stage: publish
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+19
-31
19 additions, 31 deletions
.gitlab-ci.yml
with
19 additions
and
31 deletions
.gitlab-ci.yml
+
19
−
31
View file @
a983b3d8
...
@@ -7,13 +7,10 @@ workflow:
...
@@ -7,13 +7,10 @@ workflow:
variables
:
variables
:
version
:
0.0.$CI_PIPELINE_IID
version
:
0.0.$CI_PIPELINE_IID
environment_tag
:
|
if [ "$CI_COMMIT_BRANCH" == "prod" ]; then echo "prod"; else echo "dev"; fi
stages
:
stages
:
-
test
-
test
-
build
-
build
-
tag
-
publish
-
publish
test_job
:
test_job
:
...
@@ -26,40 +23,20 @@ test_job:
...
@@ -26,40 +23,20 @@ test_job:
build_job
:
build_job
:
stage
:
build
stage
:
build
rules
:
rules
:
-
if
:
$CI_COMMIT_REF_NAME =
= "
prod
" || $CI_COMMIT_REF_NAME == "
dev
"
-
if
:
$CI_COMMIT_REF_NAME =
~ /
prod
|
dev
/
when
:
always
when
:
always
image
:
docker:latest
image
:
public.ecr.aws/docker/library/golang:1.21
services
:
script
:
|
-
docker:dind
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o artifact.bin ./*.go
tags
:
-
docker-privileged
script
:
-
docker build -t $CI_REGISTRY_IMAGE:$version -f Containerfile .
artifacts
:
artifacts
:
paths
:
paths
:
-
artifact.bin
-
artifact.bin
expire_in
:
30 min
expire_in
:
5 min
tag_job
:
stage
:
tag
rules
:
-
if
:
$CI_COMMIT_REF_NAME == "prod" || $CI_COMMIT_REF_NAME == "dev"
when
:
always
image
:
docker:latest
services
:
-
docker:dind
tags
:
-
docker-privileged
dependencies
:
-
build_job
script
:
-
docker tag $CI_REGISTRY_IMAGE:$version $CI_REGISTRY_IMAGE:latest
-
docker tag $CI_REGISTRY_IMAGE:$version $CI_REGISTRY_IMAGE:$environment_tag
publish_job
:
publish_job
:
stage
:
publish
stage
:
publish
rules
:
rules
:
-
if
:
$CI_COMMIT_REF_NAME =
= "
prod
" || $CI_COMMIT_REF_NAME == "
dev
"
-
if
:
$CI_COMMIT_REF_NAME =
~ /
prod
|
dev
/
when
:
always
when
:
always
image
:
docker:latest
image
:
docker:latest
services
:
services
:
...
@@ -67,11 +44,22 @@ publish_job:
...
@@ -67,11 +44,22 @@ publish_job:
tags
:
tags
:
-
docker-privileged
-
docker-privileged
dependencies
:
dependencies
:
-
tag
_job
-
build
_job
script
:
script
:
-
docker build -t $CI_REGISTRY_IMAGE:$version -f Containerfile .
-
docker tag $CI_REGISTRY_IMAGE:$version $CI_REGISTRY_IMAGE:latest
-
if [[ "$CI_COMMIT_BRANCH" == "prod" ]]; then
docker tag $CI_REGISTRY_IMAGE:$version $CI_REGISTRY_IMAGE:prod;
elif [[ "$CI_COMMIT_BRANCH" == "dev" ]]; then
docker tag $CI_REGISTRY_IMAGE:$version $CI_REGISTRY_IMAGE:dev;
fi
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
-
docker push $CI_REGISTRY_IMAGE:$version
-
docker push $CI_REGISTRY_IMAGE:$version
-
docker push $CI_REGISTRY_IMAGE:latest
-
docker push $CI_REGISTRY_IMAGE:latest
-
docker push $CI_REGISTRY_IMAGE:$environment_tag
-
if [[ "$CI_COMMIT_BRANCH" == "prod" ]]; then
docker push $CI_REGISTRY_IMAGE:prod;
elif [[ "$CI_COMMIT_BRANCH" == "dev" ]]; then
docker push $CI_REGISTRY_IMAGE:dev;
fi
after_script
:
after_script
:
-
docker logout $CI_REGISTRY
-
docker logout $CI_REGISTRY
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