2 Commits

Author SHA1 Message Date
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
11fc74b35d chore: update for production
Some checks failed
Build and Deploy Production / deploy (push) Has been cancelled
Build and Deploy Production / build-and-push (push) Has been cancelled
2025-09-06 18:34:30 +10:00
2 changed files with 20 additions and 8 deletions

View File

@ -1,4 +1,4 @@
IMAGE_TAG=latest
CONTAINER_NAME=comprofix
HUGO_BASEURL=https://comprofix.com
HOSTNAME=comprofix.com
HOSTNAME=comprofix.com

View File

@ -3,11 +3,11 @@ name: Build and Deploy Production
on:
push:
tags:
- "v*"
- "v*.*.*"
jobs:
build-and-push:
runs-on: ubuntu-latest
runs-on: homelab-latest
container:
image: catthehacker/ubuntu:act-latest
env:
@ -24,18 +24,24 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push Docker image
- name: Extract version from tag
id: vars
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- name: Build and push Docker images
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
tags: |
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
build-args: |
HUGO_BASEURL=https://comprofix.com/
deploy:
runs-on: ubuntu-latest
runs-on: homelab-latest
needs: build-and-push
env:
DEPLOY_USER: administrator
@ -52,10 +58,16 @@ jobs:
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
# 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..."
ssh -o StrictHostKeyChecking=no $DEPLOY_USER@$DEPLOY_HOST "
cd $DEPLOY_PATH
docker compose --env-file .env up -d
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
"