Feat/implement cicd (#1)
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
name: Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r src/requirements.txt
|
||||
- name: Lint and format with Ruff
|
||||
run: |
|
||||
pip install ruff
|
||||
ruff check src
|
||||
ruff format --check src
|
||||
|
||||
build-and-push:
|
||||
needs: test
|
||||
environment: DEV
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Lowercase repository name
|
||||
run: echo "IMAGE_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')/discord-bot" >> $GITHUB_ENV
|
||||
- name: Calculate new version
|
||||
id: version
|
||||
run: |
|
||||
NEW_MINOR=$((${{ vars.VERSION_MINOR }} + 1))
|
||||
NEW_VERSION="v${{ vars.VERSION_MAJOR }}.${NEW_MINOR}"
|
||||
echo "new_minor=$NEW_MINOR" >> "$GITHUB_OUTPUT"
|
||||
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
- uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.new_version }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
- name: Create Git tag
|
||||
run: |
|
||||
git config user.email "action@github.com"
|
||||
git config user.name "GitHub Action"
|
||||
git tag ${{ steps.version.outputs.new_version }}
|
||||
git push origin ${{ steps.version.outputs.new_version }}
|
||||
- name: Save new minor version
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.PAT_ADMIN_TOKEN }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
gh variable set VERSION_MINOR --body "${{ steps.version.outputs.new_minor }}" --env DEV
|
||||
@@ -0,0 +1,53 @@
|
||||
# Discord Meme Bot 🤖
|
||||
|
||||
A Discord bot with slash commands for meme generation and more.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.13+
|
||||
- [uv](https://docs.astral.sh/uv/) - Fast Python package manager
|
||||
- Discord Bot Token
|
||||
- n8n Webhook URL and API Key
|
||||
|
||||
## Setup
|
||||
|
||||
### Local Development
|
||||
```bash
|
||||
git clone https://github.com/EstebanVincent/DiscordBot.git
|
||||
cd DiscordBot
|
||||
cp .env.example .env # Edit with your values
|
||||
uv sync
|
||||
uv run python src/main.py
|
||||
```
|
||||
|
||||
### Docker
|
||||
```bash
|
||||
# Build and run locally
|
||||
docker build -t discord-bot .
|
||||
docker run -d --name discord-bot -e DISCORD_TOKEN=... -e WEBHOOK_URL=... -e API_KEY=... discord-bot
|
||||
|
||||
# Or use pre-built image
|
||||
docker run -d --name discord-bot -e DISCORD_TOKEN=... -e WEBHOOK_URL=... -e API_KEY=... \
|
||||
ghcr.io/estebanvincent/discordbot/discord-bot:latest
|
||||
```
|
||||
|
||||
## Commands
|
||||
|
||||
- `/meme prompt:<text>` - Generate a meme from your text prompt
|
||||
|
||||
## Discord Setup
|
||||
|
||||
1. Create bot at [Discord Developer Portal](https://discord.com/developers/applications)
|
||||
2. Copy bot token to environment variables
|
||||
3. Invite bot with permissions: Send Messages, Use Slash Commands, Embed Links
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
```bash
|
||||
# Code quality
|
||||
uv run ruff check src
|
||||
uv run ruff format src
|
||||
```
|
||||
|
||||
Project uses GitHub Actions for CI/CD with semantic versioning and automated Docker builds.
|
||||
Reference in New Issue
Block a user