Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
11fc74b35d |
@ -3,13 +3,11 @@ name: Build and Deploy Production
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- "v*"
|
- "v*.*.*"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
|
||||||
image: catthehacker/ubuntu:act-latest
|
|
||||||
env:
|
env:
|
||||||
DOCKER_REGISTRY: git.comprofix.com
|
DOCKER_REGISTRY: git.comprofix.com
|
||||||
IMAGE_NAME: mmckinnon/comprofix.com
|
IMAGE_NAME: mmckinnon/comprofix.com
|
||||||
@ -24,13 +22,19 @@ 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/
|
||||||
|
|
||||||
@ -52,10 +56,16 @@ jobs:
|
|||||||
|
|
||||||
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
|
|
||||||
|
# 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
|
||||||
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
|
||||||
"
|
"
|
||||||
|
Reference in New Issue
Block a user