mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Update .gitlab-ci.yml file
This commit is contained in:
+51
-46
@@ -2,27 +2,47 @@ stages:
|
|||||||
- build
|
- build
|
||||||
- deploy
|
- deploy
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
|
# ✅ Global defaults
|
||||||
|
# ==========================================================
|
||||||
|
default:
|
||||||
|
tags:
|
||||||
|
- self-hosted
|
||||||
|
interruptible: true
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
|
# 🏗️ Build Template
|
||||||
|
# ==========================================================
|
||||||
.build_template: &build_template
|
.build_template: &build_template
|
||||||
stage: build
|
stage: build
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
cache:
|
cache:
|
||||||
key: npm-cache
|
key: npm-cache
|
||||||
paths:
|
paths:
|
||||||
- node_modules/
|
- .npm/
|
||||||
variables:
|
variables:
|
||||||
NPM_CONFIG_PRODUCTION: 'false'
|
NPM_CONFIG_PRODUCTION: "false"
|
||||||
NODE_ENV: ''
|
NODE_ENV: ""
|
||||||
|
NPM_CONFIG_CACHE: "$CI_PROJECT_DIR/.npm"
|
||||||
script:
|
script:
|
||||||
- echo "Installing dependencies..."
|
- echo "Installing dependencies..."
|
||||||
- npm ci --no-audit --no-fund
|
- npm ci --no-audit --no-fund
|
||||||
|
|
||||||
- echo "Build env used:"
|
- echo "Build env used:"
|
||||||
- echo "NEXT_PUBLIC_LTI_URL=$NEXT_PUBLIC_LTI_URL"
|
- echo "NEXT_PUBLIC_LTI_URL=$NEXT_PUBLIC_LTI_URL"
|
||||||
- echo "NEXT_PUBLIC_SSO_LOGIN_URL=$NEXT_PUBLIC_SSO_LOGIN_URL"
|
- echo "NEXT_PUBLIC_SSO_LOGIN_URL=$NEXT_PUBLIC_SSO_LOGIN_URL"
|
||||||
- echo "NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL"
|
- echo "NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL"
|
||||||
- echo "Building Next.js static export..."
|
|
||||||
|
# Build + export (untuk static hosting di S3)
|
||||||
|
- echo "Building Next.js..."
|
||||||
- npx next build
|
- npx next build
|
||||||
|
|
||||||
|
# Kalau project kamu pakai static export:
|
||||||
|
- echo "Exporting static site..."
|
||||||
|
- npx next export
|
||||||
|
|
||||||
|
# Build metadata
|
||||||
- |
|
- |
|
||||||
mkdir -p out
|
|
||||||
cat <<EOF > out/build-info.json
|
cat <<EOF > out/build-info.json
|
||||||
{
|
{
|
||||||
"commit": "$CI_COMMIT_SHORT_SHA",
|
"commit": "$CI_COMMIT_SHORT_SHA",
|
||||||
@@ -34,11 +54,14 @@ stages:
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
artifacts:
|
artifacts:
|
||||||
name: 'out-$CI_COMMIT_SHORT_SHA'
|
name: "out-$CI_COMMIT_SHORT_SHA"
|
||||||
paths:
|
paths:
|
||||||
- out/
|
- out/
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
|
# 🚀 Deploy Template
|
||||||
|
# ==========================================================
|
||||||
.deploy_template: &deploy_template
|
.deploy_template: &deploy_template
|
||||||
stage: deploy
|
stage: deploy
|
||||||
image:
|
image:
|
||||||
@@ -82,11 +105,11 @@ stages:
|
|||||||
if [ "$STATUS" = "success" ]; then
|
if [ "$STATUS" = "success" ]; then
|
||||||
COLOR=3066993
|
COLOR=3066993
|
||||||
TITLE="✅ Deployment ${ENVIRONMENT_NAME} Succeeded"
|
TITLE="✅ Deployment ${ENVIRONMENT_NAME} Succeeded"
|
||||||
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` completed successfully."
|
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ completed successfully."
|
||||||
else
|
else
|
||||||
COLOR=15158332
|
COLOR=15158332
|
||||||
TITLE="❌ Deployment ${ENVIRONMENT_NAME} Failed"
|
TITLE="❌ Deployment ${ENVIRONMENT_NAME} Failed"
|
||||||
DESC="Deployment job on branch \`${CI_COMMIT_REF_NAME}\` encountered issues."
|
DESC="Deployment job on branch \${CI_COMMIT_REF_NAME}\ encountered issues."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jq -n \
|
jq -n \
|
||||||
@@ -114,7 +137,9 @@ stages:
|
|||||||
|
|
||||||
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
|
curl -sS -H "Content-Type: application/json" -d @payload.json "$DISCORD_WEBHOOK_URL"
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
# ==== DEVELOPMENT (Branch development) ======
|
# ==== DEVELOPMENT (Branch development) ======
|
||||||
|
# ==========================================================
|
||||||
build:dev:
|
build:dev:
|
||||||
<<: *build_template
|
<<: *build_template
|
||||||
rules:
|
rules:
|
||||||
@@ -122,25 +147,27 @@ build:dev:
|
|||||||
environment:
|
environment:
|
||||||
name: development
|
name: development
|
||||||
variables:
|
variables:
|
||||||
NEXT_PUBLIC_LTI_URL: 'https://dev-lti-erp.mbugroup.id'
|
NEXT_PUBLIC_LTI_URL: "https://dev-lti-erp.mbugroup.id"
|
||||||
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://dev-auth-erp.mbugroup.id'
|
NEXT_PUBLIC_SSO_LOGIN_URL: "https://dev-auth-erp.mbugroup.id"
|
||||||
NEXT_PUBLIC_API_BASE_URL: 'https://dev-api-lti.mbugroup.id/api'
|
NEXT_PUBLIC_API_BASE_URL: "https://dev-api-lti.mbugroup.id/api"
|
||||||
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
|
NEXT_PUBLIC_CLIENT_ID: "Lumbung-Telur-Indonesia"
|
||||||
|
|
||||||
deploy:dev:
|
deploy:dev:
|
||||||
<<: *deploy_template
|
<<: *deploy_template
|
||||||
needs: ['build:dev']
|
needs: ["build:dev"]
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == "development"'
|
- if: '$CI_COMMIT_BRANCH == "development"'
|
||||||
variables:
|
variables:
|
||||||
S3_BUCKET: 'dev-lti-erp.mbugroup.id'
|
S3_BUCKET: "dev-lti-erp.mbugroup.id"
|
||||||
AWS_REGION: 'ap-southeast-3'
|
AWS_REGION: "ap-southeast-3"
|
||||||
CLOUDFRONT_DISTRIBUTION_ID: 'E1Z8XTA8XF1GIV'
|
CLOUDFRONT_DISTRIBUTION_ID: "E1Z8XTA8XF1GIV"
|
||||||
environment:
|
environment:
|
||||||
name: development
|
name: development
|
||||||
url: https://dev-lti-erp.mbugroup.id
|
url: https://dev-lti-erp.mbugroup.id
|
||||||
|
|
||||||
|
# ==========================================================
|
||||||
# ====== STAGING (Branch staging) ======
|
# ====== STAGING (Branch staging) ======
|
||||||
|
# ==========================================================
|
||||||
build:staging:
|
build:staging:
|
||||||
<<: *build_template
|
<<: *build_template
|
||||||
rules:
|
rules:
|
||||||
@@ -148,42 +175,20 @@ build:staging:
|
|||||||
environment:
|
environment:
|
||||||
name: staging
|
name: staging
|
||||||
variables:
|
variables:
|
||||||
NEXT_PUBLIC_LTI_URL: 'https://stg-lti-erp.mbugroup.id'
|
NEXT_PUBLIC_LTI_URL: "https://stg-lti-erp.mbugroup.id"
|
||||||
NEXT_PUBLIC_SSO_LOGIN_URL: 'https://stg-auth-erp.mbugroup.id'
|
NEXT_PUBLIC_SSO_LOGIN_URL: "https://stg-auth-erp.mbugroup.id"
|
||||||
NEXT_PUBLIC_API_BASE_URL: 'https://stg-api-lti.mbugroup.id/api'
|
NEXT_PUBLIC_API_BASE_URL: "https://stg-api-lti.mbugroup.id/api"
|
||||||
NEXT_PUBLIC_CLIENT_ID: 'Lumbung-Telur-Indonesia'
|
NEXT_PUBLIC_CLIENT_ID: "Lumbung-Telur-Indonesia"
|
||||||
|
|
||||||
deploy:staging:
|
deploy:staging:
|
||||||
<<: *deploy_template
|
<<: *deploy_template
|
||||||
needs: ['build:staging']
|
needs: ["build:staging"]
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == "staging"'
|
- if: '$CI_COMMIT_BRANCH == "staging"'
|
||||||
variables:
|
variables:
|
||||||
S3_BUCKET: 'stg-lti-erp.mbugroup.id'
|
S3_BUCKET: "stg-lti-erp.mbugroup.id"
|
||||||
AWS_REGION: 'ap-southeast-3'
|
AWS_REGION: "ap-southeast-3"
|
||||||
CLOUDFRONT_DISTRIBUTION_ID: 'E2V6PPO1AUIU7H'
|
CLOUDFRONT_DISTRIBUTION_ID: "E2V6PPO1AUIU7H"
|
||||||
environment:
|
environment:
|
||||||
name: staging
|
name: staging
|
||||||
url: https://stg-lti-erp.mbugroup.id
|
url: https://stg-lti-erp.mbugroup.id
|
||||||
# ====== PRODUCTION ======
|
|
||||||
# build:production:
|
|
||||||
# <<: *build_template
|
|
||||||
# rules:
|
|
||||||
# # pilih salah satu: pakai branch master ATAU pakai tags rilis
|
|
||||||
# - if: '$CI_COMMIT_BRANCH == "master"'
|
|
||||||
# # - if: '$CI_COMMIT_TAG' # kalau mau rilis via tag, uncomment ini dan hapus baris di atas
|
|
||||||
# environment:
|
|
||||||
# name: production
|
|
||||||
|
|
||||||
# deploy:production:
|
|
||||||
# <<: *deploy_template
|
|
||||||
# needs: ["build:production"]
|
|
||||||
# rules:
|
|
||||||
# - if: '$CI_COMMIT_BRANCH == "master"'
|
|
||||||
# # - if: '$CI_COMMIT_TAG' # selaras dengan rule di build:production
|
|
||||||
# variables:
|
|
||||||
# S3_BUCKET: "lti-erp.mbugroup.id"
|
|
||||||
# CLOUDFRONT_DISTRIBUTION_ID: "ddfd"
|
|
||||||
# environment:
|
|
||||||
# name: production
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user