Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
Example CI-CD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
schmidni
Example CI-CD
Compare revisions
8c8dbeb8304ff6dac2341f745cf449ffc9514571 to da7da8414227cf611524d1880388814b41ac630f
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
schmidni/example-ci-cd
Select target project
No results found
da7da8414227cf611524d1880388814b41ac630f
Select Git revision
Branches
bedretto-environment
main
2 results
Swap
Target
schmidni/example-ci-cd
Select target project
schmidni/example-ci-cd
1 result
8c8dbeb8304ff6dac2341f745cf449ffc9514571
Select Git revision
Branches
bedretto-environment
main
2 results
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (2)
Update .gitlab-ci.yml file
· 4eadf738
schmidni
authored
1 year ago
4eadf738
Update .gitlab-ci.yml file
· da7da841
schmidni
authored
1 year ago
da7da841
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab-ci.yml
+26
-0
26 additions, 0 deletions
.gitlab-ci.yml
with
26 additions
and
0 deletions
.gitlab-ci.yml
View file @
da7da841
...
...
@@ -26,6 +26,7 @@ variables:
TAG_COMMIT
:
$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
DOCKER_TLS_CERTDIR
:
"
"
publish
:
only
:
-
/\w*-environment$/
...
...
@@ -45,3 +46,28 @@ publish:
-
docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
-
docker push $TAG_COMMIT
-
docker push $TAG_LATEST
deploy-job
:
only
:
-
/\w*-environment$/
needs
:
[
"
publish-job"
]
environment
:
name
:
${CI_COMMIT_BRANCH}
image
:
alpine:latest
stage
:
deploy
tags
:
-
deployment
script
:
-
sed -i '$a\' $ENV && echo "TAG_COMMIT=$TAG_COMMIT" >> $ENV
-
chmod og= $SERVER_RSA
-
apk update && apk add openssh-client
-
ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@${CI_ENVIRONMENT_URL#*://} "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
-
ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@${CI_ENVIRONMENT_URL#*://} "docker pull $TAG_COMMIT"
-
scp -i $SERVER_RSA -o StrictHostKeyChecking=no $ENV $SERVER_USER@${CI_ENVIRONMENT_URL#*://}:~/.env
-
scp -i $SERVER_RSA -o StrictHostKeyChecking=no docker-compose.yml $SERVER_USER@${CI_ENVIRONMENT_URL#*://}:~/docker-compose.yml
-
ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@${CI_ENVIRONMENT_URL#*://} "docker compose down"
-
ssh -i $SERVER_RSA -o StrictHostKeyChecking=no $SERVER_USER@${CI_ENVIRONMENT_URL#*://} "docker compose up -d"
This diff is collapsed.
Click to expand it.