3 Commits

Author SHA1 Message Date
c0e2a1c1f4 chore: update for host 2025-09-06 18:53:52 +10:00
50f4258a20 chore: update for host key checking
Some checks failed
Build and Deploy Production / build-and-push (push) Successful in 2m8s
Build and Deploy Production / deploy (push) Failing after 13s
2025-09-06 18:44:06 +10:00
18b38d7cc7 chore: update for production CI/CD
Some checks failed
Build and Deploy Production / build-and-push (push) Successful in 2m9s
Build and Deploy Production / deploy (push) Failing after 10s
2025-09-06 18:39:34 +10:00
2 changed files with 34 additions and 27 deletions

View File

@ -7,7 +7,9 @@ on:
jobs: jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: homelab-latest
container:
image: catthehacker/ubuntu:act-latest
env: env:
DOCKER_REGISTRY: git.comprofix.com DOCKER_REGISTRY: git.comprofix.com
IMAGE_NAME: mmckinnon/comprofix.com IMAGE_NAME: mmckinnon/comprofix.com
@ -53,19 +55,24 @@ jobs:
mkdir -p ~/.ssh mkdir -p ~/.ssh
eval $(ssh-agent -s) eval $(ssh-agent -s)
ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}") ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}")
echo "Host *" > ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
echo "Uploading docker-compose.yml and .env.production..." echo "Uploading docker-compose.yml and .env.production..."
scp docker-compose.yml $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH scp docker-compose.yml $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
scp .env.production $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/.env.production
# Replace IMAGE_TAG in .env.production with the current VERSION
sed "s/^IMAGE_TAG=.*/IMAGE_TAG=${{ env.VERSION }}/" .env.production > .env.production.new
scp .env.production.new $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/.env.production
echo "Deploying production container..." echo "Deploying production container..."
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST " ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST "
cd $DEPLOY_PATH cd $DEPLOY_PATH
# Extract Git tag that triggered the workflow
VERSION=\${GITHUB_REF#refs/tags/}
# Update IMAGE_TAG in .env.production
sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=\$VERSION/' .env.production
# Stop old container, pull new image, start container
docker compose --env-file .env.production down --remove-orphans docker compose --env-file .env.production down --remove-orphans
docker compose --env-file .env.production pull --ignore-pull-failures docker compose --env-file .env.production pull
docker compose --env-file .env.production up -d docker compose --env-file .env.production up -d
" "