1 Commits

Author SHA1 Message Date
c0e2a1c1f4 chore: update for host 2025-09-06 18:53:52 +10:00

View File

@ -41,36 +41,38 @@ jobs:
HUGO_BASEURL=https://comprofix.com/
deploy:
runs-on: homelab-latest
needs: build-and-push
env:
DEPLOY_USER: administrator
DEPLOY_HOST: docker.comprofix.xyz
DEPLOY_PATH: /opt/comprofix
steps:
- uses: actions/checkout@v4
runs-on: ubuntu-latest
needs: build-and-push
env:
DEPLOY_USER: administrator
DEPLOY_HOST: docker.comprofix.xyz
DEPLOY_PATH: /opt/comprofix
steps:
- uses: actions/checkout@v4
- name: Deploy to production server
run: |
mkdir -p ~/.ssh
eval $(ssh-agent -s)
ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}")
echo "HOST *" > ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
echo "nameserver 10.10.10.1" > /etc/resolv.conf
- name: Deploy to production server
run: |
mkdir -p ~/.ssh
eval $(ssh-agent -s)
ssh-add <(echo "${{ secrets.SSH_PRIVATE_KEY }}")
echo "Host *" > ~/.ssh/config
echo "StrictHostKeyChecking no" >> ~/.ssh/config
echo "Uploading docker-compose.yml and .env.production..."
scp docker-compose.yml $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
echo "Uploading docker-compose.yml and .env.production..."
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
echo "Deploying production container..."
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST "
cd $DEPLOY_PATH
# Extract Git tag that triggered the workflow
VERSION=\${GITHUB_REF#refs/tags/}
scp .env.production.new $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/.env.production
# Update IMAGE_TAG in .env.production
sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=\$VERSION/' .env.production
echo "Deploying production container..."
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST "
cd $DEPLOY_PATH
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 up -d
"
# Stop old container, pull new image, start container
docker compose --env-file .env.production down --remove-orphans
docker compose --env-file .env.production pull
docker compose --env-file .env.production up -d
"