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:
+17
-18
@@ -14,9 +14,9 @@ stages:
|
||||
NPM_CONFIG_PRODUCTION: "false"
|
||||
NODE_ENV: ""
|
||||
script:
|
||||
- echo "🧩 Installing dependencies..."
|
||||
- echo "Installing dependencies..."
|
||||
- npm ci --no-audit --no-fund
|
||||
- echo "⚙️ Building Next.js static export..."
|
||||
- echo "Building Next.js static export..."
|
||||
- npx next build
|
||||
artifacts:
|
||||
name: "out-$CI_COMMIT_SHORT_SHA"
|
||||
@@ -24,44 +24,43 @@ stages:
|
||||
- out/
|
||||
expire_in: 1 week
|
||||
|
||||
# ====== TEMPLATE: DEPLOY KE S3 + CLOUDFRONT + NOTICE DISCORD ======
|
||||
.deploy_template: &deploy_template
|
||||
stage: deploy
|
||||
image:
|
||||
name: amazon/aws-cli:latest
|
||||
entrypoint: ["/bin/sh", "-c"]
|
||||
script:
|
||||
- set -e
|
||||
- aws --version
|
||||
- echo "🧹 Cleaning up newline characters in AWS credentials..."
|
||||
- echo "Cleaning up newline characters in AWS credentials..."
|
||||
- export AWS_ACCESS_KEY_ID=$(echo $AWS_ACCESS_KEY_ID | tr -d '\r\n')
|
||||
- export AWS_SECRET_ACCESS_KEY=$(echo $AWS_SECRET_ACCESS_KEY | tr -d '\r\n')
|
||||
- echo "🚀 Deploying to s3://$S3_BUCKET in region $AWS_REGION"
|
||||
- echo "Deploying to s3://$S3_BUCKET in region $AWS_REGION"
|
||||
- aws s3api head-bucket --bucket "$S3_BUCKET" --region "$AWS_REGION" || aws s3api create-bucket --bucket "$S3_BUCKET" --region "$AWS_REGION" --create-bucket-configuration LocationConstraint="$AWS_REGION"
|
||||
- aws s3 sync ./out "s3://$S3_BUCKET" --delete --region "$AWS_REGION" --endpoint-url "https://s3.ap-southeast-3.amazonaws.com"
|
||||
|
||||
# CloudFront invalidation
|
||||
- |
|
||||
STATUS="success"
|
||||
if [ -n "$CLOUDFRONT_DISTRIBUTION_ID" ]; then
|
||||
echo "📦 Invalidating CloudFront cache..."
|
||||
aws cloudfront create-invalidation \
|
||||
--distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" \
|
||||
--paths "/*"
|
||||
echo "Invalidating CloudFront cache..."
|
||||
if ! aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --paths "/*"; then
|
||||
echo "CloudFront invalidation failed."
|
||||
STATUS="failed"
|
||||
fi
|
||||
else
|
||||
echo "ℹ️ No CloudFront distribution specified — skipping invalidation"
|
||||
echo "No CloudFront distribution specified — skipping invalidation"
|
||||
fi
|
||||
if [ "$CI_JOB_STATUS" = "success" ]; then
|
||||
STATUS='success'
|
||||
else
|
||||
STATUS='failed'
|
||||
fi
|
||||
# 🔔 Notifikasi Discord
|
||||
|
||||
# Notifikasi Discord
|
||||
- |
|
||||
RUN_URL="${CI_PROJECT_URL}/-/pipelines/${CI_PIPELINE_ID}"
|
||||
|
||||
# Tentukan nama environment untuk pesan
|
||||
# Tentukan nama environment
|
||||
if [ "$CI_COMMIT_BRANCH" = "devops-s3" ]; then
|
||||
ENVIRONMENT_NAME="WEB-LTI-DEV"
|
||||
elif [ "$CI_COMMIT_BRANCH" = "master" ]; then
|
||||
ENVIRONMENT_NAME="WEB-LTI-DEV"
|
||||
ENVIRONMENT_NAME="WEB-LTI-PROD"
|
||||
else
|
||||
ENVIRONMENT_NAME="UNKNOWN"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user