Skip to content
This repository was archived by the owner on Apr 15, 2026. It is now read-only.

Merge pull request #22 from tancred423/7-alt-tags #65

Merge pull request #22 from tancred423/7-alt-tags

Merge pull request #22 from tancred423/7-alt-tags #65

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
jobs:
check:
name: Check Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v2.5.6
- name: Check formatting
run: deno fmt --check
- name: Run linter
run: deno lint
- name: Type check
run: deno check src/**/*.ts
build:
name: Build and Push Docker Image
runs-on: ubuntu-latest
needs: check
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get lowercase repository name
id: repo
run: |
REPO_LOWER=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
echo "repo=$REPO_LOWER" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
ghcr.io/${{ steps.repo.outputs.repo }}:latest
ghcr.io/${{ steps.repo.outputs.repo }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: Deploy to Server
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Copy docker-compose.prod.yml to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
source: "docker-compose.prod.yml"
target: ${{ secrets.DEPLOY_PATH }}
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
script: |
set -e
cd ${{ secrets.DEPLOY_PATH }}
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin
echo "Stopping existing containers..."
docker compose -f docker-compose.prod.yml down --volumes=false || true
echo "Pulling latest images..."
docker compose -f docker-compose.prod.yml pull
echo "Starting containers..."
DEPLOYMENT_HASH=${{ github.sha }} docker compose -f docker-compose.prod.yml up -d --remove-orphans
echo "Checking container status..."
docker compose -f docker-compose.prod.yml ps
echo "Deploying Discord commands..."
docker exec naago-app deno run --allow-all src/deploy-commands.ts
echo "Cleaning up old images..."
docker image prune -af --filter "until=24h" || true
echo "Deployment completed successfully!"