Merge branch 'pipeline-refactoring' into 'dev'

Update CI images with digests and remove redundant declarations

See merge request rheinsw/website!14
This commit is contained in:
2025-03-29 22:19:30 +00:00
parent df69bd3aab
commit b1cc973853
2 changed files with 25 additions and 31 deletions

View File

@@ -24,6 +24,11 @@ variables:
PROJECT_NAME: $CI_PROJECT_NAME
DOCKER_IMAGE: "registry.boomlab.party/rheinsw/$CI_PROJECT_NAME"
.deploy_production_rule: &deploy_production_rule
- if: $CI_COMMIT_BRANCH == "production"
when: manual
allow_failure: true
# Reusable SSH key setup block
.install_deploy_key: &install_deploy_key
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
@@ -34,11 +39,6 @@ variables:
- ssh-add ~/.ssh/deploy_key
- ssh-keyscan -p 22 -H '192.168.41.101' >> ~/.ssh/known_hosts || true
.deploy_production_rule: &deploy_production_rule
- if: $CI_COMMIT_BRANCH == "production"
when: manual
allow_failure: true
.deploy_script: &deploy_script
- |
echo "Deploying $DOCKER_IMAGE:$TAG to $CONTAINER_NAME on port $PORT..."
@@ -61,26 +61,30 @@ build:
dockerize:
stage: docker
image: docker:20.10@sha256:2967f0819c84dd589ed0a023b9d25dcfe7a3c123d5bf784ffbb77edf55335f0c
services:
- docker:dind
before_script:
- echo "$CI_REGISTRY_PASSWORD" | docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" --password-stdin
script:
- |
if [[ "$CI_COMMIT_REF_NAME" == "production" ]]; then
TAG="latest"
elif [[ "$CI_COMMIT_REF_NAME" == "dev" ]]; then
TAG="dev"
else
echo "Skipping Docker build for branch $CI_COMMIT_REF_NAME"
exit 0
fi
echo "Using tag: $TAG"
TAG="$CI_COMMIT_REF_NAME"
echo "Building Docker image with tag: $TAG"
docker build -t $DOCKER_IMAGE:$TAG -f Dockerfile .
docker push $DOCKER_IMAGE:$TAG
only:
- dev
- production
if [[ "$TAG" == "dev" || "$TAG" == "production" ]]; then
echo "Pushing Docker image $DOCKER_IMAGE:$TAG"
docker push $DOCKER_IMAGE:$TAG
else
echo "Skipping Docker push for non-dev or production branch: $TAG"
fi
deploy_production:
stage: deploy
rules: *deploy_production_rule
before_script: *install_deploy_key
script:
- TAG="production"
- PORT="4100"
- CONTAINER_NAME="$CI_PROJECT_NAME-production"
- *deploy_script
deploy_dev:
stage: deploy
@@ -93,16 +97,6 @@ deploy_dev:
only:
- dev
deploy_production:
stage: deploy
rules: *deploy_production_rule
before_script: *install_deploy_key
script:
- TAG="latest"
- PORT="4100"
- CONTAINER_NAME="$CI_PROJECT_NAME-production"
- *deploy_script
sync_branches:
stage: sync
rules: