9 Commits

Author SHA1 Message Date
c294443e8d fix: add nameserver
All checks were successful
Build and Deploy Production / build-and-push (push) Successful in 2m4s
Build and Deploy Production / deploy (push) Successful in 16s
2025-09-06 20:56:44 +10:00
6cb3699016 fix: update to deploy on correct location
All checks were successful
Build and Deploy Production / build-and-push (push) Successful in 2m9s
Build and Deploy Production / deploy (push) Successful in 15s
2025-09-06 19:20:30 +10:00
2734dd8c58 fix: update to deploy on correct location
Some checks failed
Build and Deploy Production / build-and-push (push) Successful in 2m6s
Build and Deploy Production / deploy (push) Failing after 11s
2025-09-06 19:06:09 +10:00
f191fe9e4a fix: formatting so deploy runs
Some checks failed
Build and Deploy Production / build-and-push (push) Successful in 2m6s
Build and Deploy Production / deploy (push) Failing after 4s
2025-09-06 18:58:04 +10:00
cc46db0cb3 chore: update for production run
All checks were successful
Build and Deploy Production / build-and-push (push) Successful in 2m8s
2025-09-06 18:55:08 +10:00
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
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 23 additions and 7 deletions

View File

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

View File

@ -7,7 +7,7 @@ on:
jobs: jobs:
build-and-push: build-and-push:
runs-on: ubuntu-latest runs-on: homelab-latest
container: container:
image: catthehacker/ubuntu:act-latest image: catthehacker/ubuntu:act-latest
env: env:
@ -24,23 +24,30 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }} username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }} 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 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./Dockerfile file: ./Dockerfile
push: true 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: | build-args: |
HUGO_BASEURL=https://comprofix.com/ HUGO_BASEURL=https://comprofix.com/
deploy: deploy:
runs-on: ubuntu-latest runs-on: homelab-latest
needs: build-and-push needs: build-and-push
env: env:
DEPLOY_USER: administrator DEPLOY_USER: administrator
DEPLOY_HOST: docker.comprofix.xyz DEPLOY_HOST: docker.comprofix.xyz
DEPLOY_PATH: /opt/comprofix DEPLOY_PATH: /opt/comprofix
VERSION: ${{ github.ref_name }} # <-- get the tag that triggered this workflow
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -49,13 +56,22 @@ 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 "nameserver 10.10.10.1" > /etc/resolv.conf
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 scp .env.production $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
docker compose --env-file .env up -d # Replace IMAGE_TAG with the version from CI
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 pull
docker compose --env-file .env.production up -d
" "