Skip to content

Update CHANGELOG.md #10

Update CHANGELOG.md

Update CHANGELOG.md #10

Workflow file for this run

name: Deploy
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
REGISTRY: ghcr.io
IMAGE_NAME: aussiebroadwan/tony
CONTAINER_NAME: tab-tony
DATABASE_HOST: postgres
DATABASE_NAME: tony
DISCORD_BOT_CHANNEL: tony-dev
jobs:
build:
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Login to the Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Build and push Docker image with Buildx
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}
deploy:
needs: build
runs-on: deploy
steps:
# Login to the Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Create or use existing Docker network
- name: Create Docker Network
run: docker network create tony-network || true
# Ensure PostgreSQL is running
- name: Start PostgreSQL Container
run: |
docker pull postgres:latest
docker volume create pgdata || true
docker run --name ${{ env.DATABASE_HOST }} \
-e POSTGRES_DB=${{ env.DATABASE_NAME }} \
-e POSTGRES_USER=${{ secrets.DATABASE_USER }} \
-e POSTGRES_PASSWORD=${{ secrets.DATABASE_PASSWORD }} \
--network tony-network \
-v pgdata:/var/lib/postgresql/data \
-d --restart unless-stopped postgres:latest || true
# Pull the Docker image
- name: Pull ${{ github.ref_name}}
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}
# Stop and Remove the existing container
- name: Replace Existing Container
run: |
docker stop ${{ env.CONTAINER_NAME }} || true
docker rm ${{ env.CONTAINER_NAME }} || true
# Deploy the Docker image
- name: Deploy ${{ github.ref_name}}
run: |
docker run --name=${{ env.CONTAINER_NAME }} \
-e TONY_VERSION=${{ github.ref_name }} \
-e DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} \
-e DISCORD_SERVER_ID=${{ secrets.DISCORD_SERVER_ID }} \
-e DISCORD_STARTUP_CHANNEL=${{ env.DISCORD_BOT_CHANNEL }} \
-e DB_HOST=${{ env.DATABASE_HOST }} \
-e DB_NAME=${{ env.DATABASE_NAME }} \
-e DB_USER=${{ secrets.DATABASE_USER }} \
-e DB_PASSWORD=${{ secrets.DATABASE_PASSWORD }} \
--network tony-network \
-d --restart unless-stopped ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}