Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
6cb3699016 | |||
2734dd8c58 | |||
f191fe9e4a | |||
cc46db0cb3 |
@ -3,7 +3,7 @@ name: Build and Deploy Production
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*"
|
- "v*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
@ -41,12 +41,13 @@ jobs:
|
|||||||
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
|
||||||
|
|
||||||
@ -65,11 +66,8 @@ jobs:
|
|||||||
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
|
# Replace IMAGE_TAG with the version from CI
|
||||||
VERSION=\${GITHUB_REF#refs/tags/}
|
sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=${VERSION}/' .env.production
|
||||||
|
|
||||||
# Update IMAGE_TAG in .env.production
|
|
||||||
sed -i 's/^IMAGE_TAG=.*/IMAGE_TAG=\$VERSION/' .env.production
|
|
||||||
|
|
||||||
# Stop old container, pull new image, start container
|
# 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
|
||||||
|
Reference in New Issue
Block a user