Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
c294443e8d | |||
6cb3699016 | |||
2734dd8c58 | |||
f191fe9e4a | |||
cc46db0cb3 |
@ -3,7 +3,7 @@ name: Build and Deploy Production
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
@ -41,12 +41,13 @@ jobs:
|
||||
HUGO_BASEURL=https://comprofix.com/
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: homelab-latest
|
||||
needs: build-and-push
|
||||
env:
|
||||
DEPLOY_USER: administrator
|
||||
DEPLOY_HOST: docker.comprofix.xyz
|
||||
DEPLOY_PATH: /opt/comprofix
|
||||
VERSION: ${{ github.ref_name }} # <-- get the tag that triggered this workflow
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@ -57,6 +58,7 @@ jobs:
|
||||
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..."
|
||||
scp docker-compose.yml $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH
|
||||
@ -65,11 +67,8 @@ jobs:
|
||||
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/}
|
||||
|
||||
# Update IMAGE_TAG in .env.production
|
||||
sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=\$VERSION/' .env.production
|
||||
# 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
|
||||
|
Reference in New Issue
Block a user