Skip to content

Commit

Permalink
feat: prepare env var for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
SkellyBG committed Feb 20, 2024
1 parent 13c7f7d commit 39a0752
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DISCORD_TOKEN: insert_bot_token_here
18 changes: 18 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Deploy to Fly

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
6 changes: 2 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import discord
from discord.ext import commands
from src.config import config

TOKEN = ""

Expand Down Expand Up @@ -28,7 +29,4 @@ async def sync(ctx: commands.context.Context):
print(e)


with open(".token", "r") as t:
TOKEN = t.readline().strip()

bot.run(TOKEN)
bot.run(config["DISCORD_TOKEN"])
12 changes: 11 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
discord
aiohttp==3.9.3
aiosignal==1.3.1
async-timeout==4.0.3
attrs==23.2.0
discord==2.3.2
discord.py==2.3.2
frozenlist==1.4.1
idna==3.6
multidict==6.0.5
python-dotenv==1.0.1
yarl==1.9.4
9 changes: 9 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os
from dotenv import load_dotenv

load_dotenv()

config: dict[str, str] = {
"DISCORD_TOKEN": os.environ["DISCORD_TOKEN"],
"DATABASE_URL": os.environ["DATABASE_URL"],
}

0 comments on commit 39a0752

Please sign in to comment.