Files
lti-web-client/.gitlab-ci.yml
T
2025-11-10 08:26:05 +00:00

93 lines
2.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
stages:
- build
- deploy
# ====== TEMPLATE: BUILD STATIC NEXT.JS ======
.build_template: &build_template
stage: build
image: node:20-alpine
cache:
key: npm-cache
paths:
- node_modules/
variables:
NPM_CONFIG_PRODUCTION: "false"
NODE_ENV: ""
script:
- echo "🧩 Installing dependencies..."
- npm ci --no-audit --no-fund
- echo "⚙️ Building Next.js static export..."
- npx next build
artifacts:
name: "out-$CI_COMMIT_SHORT_SHA"
paths:
- out/
expire_in: 1 week
# ====== TEMPLATE: DEPLOY KE S3 + CLOUDFRONT ======
.deploy_template: &deploy_template
stage: deploy
image:
name: amazon/aws-cli:latest
entrypoint: ["/bin/sh", "-c"]
script:
- aws --version
- echo "🚀 Deploying to s3://$S3_BUCKET in region $AWS_REGION"
- aws s3 sync ./out "s3://$S3_BUCKET" --delete --region "$AWS_REGION"
- |
if [ -n "$CLOUDFRONT_DISTRIBUTION_ID" ]; then
echo "📦 Invalidating CloudFront cache..."
aws cloudfront create-invalidation \
--distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" \
--paths "/*"
else
echo "️ No CloudFront distribution specified — skipping invalidation"
fi
# ====== DEVELOPMENT (Branch devops-s3) ======
build:dev:
<<: *build_template
rules:
- if: '$CI_COMMIT_BRANCH == "devops-s3"'
environment:
name: devops-s3
variables:
NEXT_PUBLIC_API_BASE_URL: "https://dev-api-lti.mbugroup.id"
NEXT_PUBLIC_SSO_LOGIN_URL: "https://dev-api-sso.mbugroup.id"
deploy:dev:
<<: *deploy_template
needs: ["build:dev"]
rules:
- if: '$CI_COMMIT_BRANCH == "devops-s3"'
variables:
S3_BUCKET: "web-lti-dev"
AWS_DEFAULT_REGION: "ap-southeast-1"
CLOUDFRONT_DISTRIBUTION_ID: "E1Z8XTA8XF1GIV"
environment:
name: devops-s3
url: dev-lti-erp.mbugroup.id.s3.ap-southeast-3.amazonaws.com
# ====== 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
# url: https://royalgoldcapital.com