Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
c294443e8d | |||
6cb3699016 | |||
2734dd8c58 | |||
f191fe9e4a | |||
cc46db0cb3 | |||
c0e2a1c1f4 |
@ -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:
|
||||||
@ -47,6 +47,7 @@ jobs:
|
|||||||
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
|
||||||
|
|
||||||
@ -55,22 +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 "Host *" > ~/.ssh/config
|
||||||
echo "StrictHostKeyChecking no" >> ~/.ssh/config
|
echo "StrictHostKeyChecking no" >> ~/.ssh/config
|
||||||
echo "nameserver 10.10.10.1" > /etc/resolv.conf
|
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.production
|
||||||
# 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..."
|
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
|
||||||
|
# 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 down --remove-orphans
|
||||||
docker compose --env-file .env.production pull --ignore-pull-failures
|
docker compose --env-file .env.production pull
|
||||||
docker compose --env-file .env.production up -d
|
docker compose --env-file .env.production up -d
|
||||||
"
|
"
|
||||||
|
Reference in New Issue
Block a user