Skip to content

Commit 9a04c00

Browse files
committed
fix: Fix deployment logic
1 parent 753cf4e commit 9a04c00

File tree

2 files changed

+8
-32
lines changed

2 files changed

+8
-32
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ jobs:
6464
echo "Deploying $IMAGE to VPS..."
6565
ssh -o StrictHostKeyChecking=no ${{ secrets.DEPLOYMENT_SSH_USER }}@${{ secrets.DEPLOYMENT_SERVER }} "\
6666
export PROJECT_NAME='${{ vars.PROJECT_NAME }}' && \
67-
export DEPLOY_ENV='${{ inputs.target_env }}' && \
6867
export GHCR_USER='${{ secrets.MACHINE_USER }}' && \
6968
export GHCR_PAT='${{ secrets.MACHINE_PAT }}' && \
7069
export APPLICATION_IMAGE='$IMAGE' && \

scripts/deploy.sh

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ if [ -z "$APPLICATION_IMAGE" ]; then
77
exit 1
88
fi
99

10-
# Checks if deployment environment is specified
11-
if [ -z "$DEPLOY_ENV" ]; then
12-
echo "[ERROR] DEPLOY_ENV variable not set. Please set it to 'dev' or 'prod'."
13-
exit 1
14-
fi
15-
16-
# Defines path to deployment files
17-
COMPOSE_PATH="/opt/rcb-deployments/discord-bot"
18-
1910
# Logs into GHCR using provided credentials (from GitHub CI/CD)
2011
echo "Logging into GitHub Container Registry..."
2112
echo "${GHCR_PAT}" | docker login ghcr.io -u "${GHCR_USER}" --password-stdin
@@ -24,34 +15,20 @@ echo "${GHCR_PAT}" | docker login ghcr.io -u "${GHCR_USER}" --password-stdin
2415
echo "Pulling image: $APPLICATION_IMAGE"
2516
docker pull "$APPLICATION_IMAGE"
2617

27-
# Prepares env and compose files based on environment
28-
if [ "$DEPLOY_ENV" == "production" ]; then
29-
OVERRIDE_FILE="$COMPOSE_PATH/docker-compose.prod.yml"
30-
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.prod.yml"
31-
ENV_FILE="--env-file .env.prod"
32-
elif [ "$DEPLOY_ENV" == "development" ]; then
33-
OVERRIDE_FILE="$COMPOSE_PATH/docker-compose.dev.yml"
34-
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.dev.yml"
35-
ENV_FILE="--env-file .env.development"
36-
else
37-
echo "[ERROR] Unknown DEPLOY_ENV: $DEPLOY_ENV. Expected 'development' or 'production'."
38-
exit 1
39-
fi
18+
# Changes directory to where the deployment files are
19+
cd "/opt/rcb-deployments/$PROJECT_NAME"
4020

4121
# Replaces placeholder string '${APPLICATION_IMAGE}' with the actual image within compose file.
42-
echo "Injecting image into override file ($OVERRIDE_FILE)..."
43-
sed -i "s|\${APPLICATION_IMAGE}|$APPLICATION_IMAGE|g" "$OVERRIDE_FILE"
44-
45-
# Changes directory to where the deployment files are
46-
cd "$COMPOSE_PATH"
22+
echo "Injecting image to override docker compose file..."
23+
sed -i "s|\${APPLICATION_IMAGE}|$APPLICATION_IMAGE|g" ./docker-compose.override.yml
4724

4825
# Tears down existing containers
49-
echo "Stopping existing containers for environment: $DEPLOY_ENV..."
50-
docker compose -p "$PROJECT_NAME" $COMPOSE_FILES down
26+
echo "Stopping existing containers..."
27+
docker compose -p "$PROJECT_NAME" down
5128

5229
# Brings up new containers
53-
echo "Starting docker-compose for environment: $DEPLOY_ENV..."
54-
docker compose -p "$PROJECT_NAME" $ENV_FILE $COMPOSE_FILES up -d --build
30+
echo "Starting new containers..."
31+
docker compose -p "$PROJECT_NAME" up -d --build
5532

5633
# Cleans up unused docker images
5734
echo "Pruning unused Docker images..."

0 commit comments

Comments
 (0)