Compare commits

...

12 Commits

Author SHA1 Message Date
kris 7a6b3121f6 Update .gitlab-ci.yml file 2025-12-01 04:37:25 +00:00
kris 92901bc60c Update .gitlab-ci.yml file 2025-12-01 04:35:16 +00:00
GitLab Deploy Bot 2ea2e1ddf3 Merge remote-tracking branch 'origin/development' into devops-ec2 2025-12-01 11:26:27 +07:00
kris 8f4548971e Update .gitlab-ci.yml file 2025-11-11 09:23:32 +00:00
kris d940580152 Update .gitlab-ci.yml file 2025-11-11 09:18:02 +00:00
kris c8052f4cb5 Update .gitlab-ci.yml file 2025-11-11 09:09:50 +00:00
kris b8dca3c25e Update .gitlab-ci.yml file 2025-11-11 09:07:45 +00:00
kris c885fba4ef Update .gitlab-ci.yml file 2025-11-11 08:53:59 +00:00
kris 4837ed4255 Update .gitlab-ci.yml file 2025-11-11 08:45:25 +00:00
kris d740a3e26e Update .gitlab-ci.yml file 2025-11-11 08:36:36 +00:00
kris 0766cfeeb2 Update .gitlab-ci.yml file 2025-11-11 08:28:54 +00:00
kris 8e89f9fad0 Update .gitlab-ci.yml file 2025-11-11 08:26:37 +00:00
+28 -6
View File
@@ -6,24 +6,45 @@ deploy-dev:
image: alpine:3.20 image: alpine:3.20
variables: variables:
DEPLOY_APP: "LTI-MBUGROUP" DEPLOY_APP: "LTI-MBUGROUP"
# Opsional: kalau pakai submodule, ini bikin clone submodule pakai SSH juga
GIT_SUBMODULE_STRATEGY: recursive
GIT_DEPTH: "1"
before_script: before_script:
- echo "🧰 Installing dependencies..." - echo "🧰 Installing dependencies..."
- apk update && apk add --no-cache openssh git curl - apk update && apk add --no-cache openssh git curl bash
# Setup SSH di runner
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa
- eval $(ssh-agent -s) - eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa - ssh-add ~/.ssh/id_rsa
# Trust host keys (server + gitlab) biar SSH gak nanya interaktif
- ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts - ssh-keyscan -H "$SERVER_IP" >> ~/.ssh/known_hosts
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
script: script:
- echo "🚀 Deploying latest code to $SERVER_USER@$SERVER_IP" - echo "🚀 Deploying latest code to $SERVER_USER@$SERVER_IP"
- > - >
if ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" " if ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" "
cd /home/devops/docker/deployment/development/lti-api && set -e
git fetch origin development &&
git reset --hard origin/development && cd /home/devops/docker/deployment/development/lti-api
# Pastikan remote origin SSH (antisipasi kalau pernah ke-set HTTPS)
git remote set-url origin git@gitlab.com:mbugroup/lti-api.git
# Pastikan server percaya gitlab.com juga (untuk git fetch via SSH)
mkdir -p ~/.ssh
ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
# Fetch/reset pakai SSH
GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no' git fetch origin development
git reset --hard origin/development
docker compose restart dev-api-lti || docker compose up -d dev-api-lti docker compose restart dev-api-lti || docker compose up -d dev-api-lti
"; then "; then
STATUS='success'; STATUS='success';
@@ -64,6 +85,7 @@ deploy-dev:
only: only:
- development - development
- devops-ec2
environment: environment:
name: development name: development