Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
.git
.github
*.exe
/frodo-bot
68 changes: 68 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Deploy

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

permissions:
contents: read

env:
IMAGE: ghcr.io/simonkimdev/frodo-bot

jobs:
image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Pull requests only check that the image builds; main also pushes it.
- uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.ref == 'refs/heads/main' }}
tags: |
${{ env.IMAGE }}:${{ github.sha }}
${{ env.IMAGE }}:latest
labels: org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
needs: image
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
concurrency: deploy
permissions:
contents: read
id-token: write
steps:
- uses: azure/login@v2
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

- name: Deploy the new image
run: |
az config set extension.use_dynamic_install=yes_without_prompt
az containerapp update \
--name "${{ vars.AZURE_CONTAINER_APP }}" \
--resource-group "${{ vars.AZURE_RESOURCE_GROUP }}" \
--image "${{ env.IMAGE }}:${{ github.sha }}" \
--output none
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# syntax=docker/dockerfile:1

FROM golang:1.26-alpine AS build
WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o /out/frodo-bot ./cmd/frodo-bot

# distroless/static has CA certificates (needed for Discord's TLS) and nothing else; runs as a non-root user.
FROM gcr.io/distroless/static-debian12:nonroot
COPY --from=build /out/frodo-bot /frodo-bot
ENTRYPOINT ["/frodo-bot"]
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@
A Discord bot that does one thing: whenever someone says "secret",
bot replies with "Alright then, keep your secrets."

## Setup
## Add Frodo to your server

**[Invite Frodo](https://discord.com/oauth2/authorize?client_id=1561964364746195014&permissions=84992&integration_type=0&scope=bot+applications.commands)**

This is a hosted instance that always runs the latest `main` of this repo, so there's nothing to set up.
If you'd rather run your own, see [Self-hosting](#self-hosting).

## Commands

| Command | Description |
| ------------- | ------------------------------------------------------------------- |
| /morgul-blade | Stab Frodo with the cursed Morgul blade to silence him indefinitely |

## Self-hosting

### Pre-Requisite

Only the self hosting is supported atm. You'd need to register your own bot on discord dev portal.
Register your own bot on the [Discord Developer Portal](https://discord.com/developers/applications),
and enable **Message Content Intent** in its Bot tab. Invite it with the `bot` and
`applications.commands` scopes.

### 1. Configure

Expand All @@ -28,11 +43,12 @@ Then fill in `.env`:
go run ./cmd/frodo-bot
```

### 3. Supported Commands
Or with Docker:

| Command | Description |
| ------------- | ------------------------------------------------------------------- |
| /morgul-blade | Stab Frodo with the cursed Morgul blade to silence him indefinitely |
```bash
docker build -t frodo-bot .
docker run --rm --env-file .env frodo-bot
```

Press `Ctrl+C` to stop.

Expand Down
Loading