mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-25 07:45:44 +00:00
Update CICD
This commit is contained in:
+21
-19
@@ -6,31 +6,31 @@ stages:
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
tags:
|
tags:
|
||||||
- self-hosted-stg
|
- self-hosted-prod
|
||||||
|
|
||||||
workflow:
|
workflow:
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "production"'
|
||||||
when: always
|
when: always
|
||||||
- when: never
|
- when: never
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
DOCKER_BUILDKIT: "1"
|
DOCKER_BUILDKIT: "1"
|
||||||
|
|
||||||
IMAGE_TAG: "staging_${CI_COMMIT_SHORT_SHA}"
|
IMAGE_TAG: "production_${CI_COMMIT_SHORT_SHA}"
|
||||||
IMAGE_NAME: "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
|
IMAGE_NAME: "${CI_REGISTRY_IMAGE}:${IMAGE_TAG}"
|
||||||
IMAGE_LATEST: "${CI_REGISTRY_IMAGE}:staging_latest"
|
IMAGE_LATEST: "${CI_REGISTRY_IMAGE}:production_latest"
|
||||||
|
|
||||||
DEPLOY_DIR: "/opt/deploy/stg-lti-api"
|
DEPLOY_DIR: "/opt/deploy/lti"
|
||||||
COMPOSE_FILE: "docker-compose.yaml"
|
COMPOSE_FILE: "docker-compose.yaml"
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# BUILD (AUTO)
|
# BUILD (AUTO)
|
||||||
# =========================
|
# =========================
|
||||||
build_staging:
|
build_production:
|
||||||
stage: build
|
stage: build
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "production"'
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
docker info
|
docker info
|
||||||
@@ -51,16 +51,16 @@ build_staging:
|
|||||||
# =========================
|
# =========================
|
||||||
# MIGRATE (AUTO)
|
# MIGRATE (AUTO)
|
||||||
# =========================
|
# =========================
|
||||||
migrate_staging:
|
migrate_production:
|
||||||
stage: migrate
|
stage: migrate
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "production"'
|
||||||
needs:
|
needs:
|
||||||
- job: build_staging
|
- job: build_production
|
||||||
artifacts: false
|
artifacts: false
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
echo "✅ Running migrations (staging) ..."
|
echo "✅ Running migrations (production) ..."
|
||||||
|
|
||||||
cd "$DEPLOY_DIR"
|
cd "$DEPLOY_DIR"
|
||||||
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
|
test -f "$COMPOSE_FILE" || (echo "❌ $COMPOSE_FILE not found in $DEPLOY_DIR" && exit 1)
|
||||||
@@ -128,14 +128,14 @@ migrate_staging:
|
|||||||
# =========================
|
# =========================
|
||||||
# DEPLOY (AUTO)
|
# DEPLOY (AUTO)
|
||||||
# =========================
|
# =========================
|
||||||
deploy_staging:
|
deploy_production:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "production"'
|
||||||
needs:
|
needs:
|
||||||
- job: migrate_staging
|
- job: migrate_production
|
||||||
artifacts: false
|
artifacts: false
|
||||||
- job: build_staging
|
- job: build_production
|
||||||
artifacts: false
|
artifacts: false
|
||||||
script: |
|
script: |
|
||||||
set -e
|
set -e
|
||||||
@@ -154,12 +154,12 @@ deploy_staging:
|
|||||||
# =========================
|
# =========================
|
||||||
# SEED (MANUAL)
|
# SEED (MANUAL)
|
||||||
# =========================
|
# =========================
|
||||||
seed_staging:
|
seed_production:
|
||||||
stage: seed
|
stage: seed
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "production"'
|
||||||
needs:
|
needs:
|
||||||
- job: deploy_staging
|
- job: deploy_production
|
||||||
artifacts: false
|
artifacts: false
|
||||||
when: manual
|
when: manual
|
||||||
allow_failure: false
|
allow_failure: false
|
||||||
@@ -170,4 +170,6 @@ seed_staging:
|
|||||||
test -f .env || (echo "❌ .env not found" && exit 1)
|
test -f .env || (echo "❌ .env not found" && exit 1)
|
||||||
|
|
||||||
docker compose -f "$COMPOSE_FILE" pull seed || true
|
docker compose -f "$COMPOSE_FILE" pull seed || true
|
||||||
docker compose -f "$COMPOSE_FILE" run --rm seed
|
docker compose -f "$COMPOSE_FILE" run --rm seed
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user