diff --git a/.dockerignore b/.dockerignore index b149553..ddc3bf9 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,9 @@ +# Files +.env + +# Folders +.git .github +.dockerignore +Dockerfile venv \ No newline at end of file diff --git a/.env.example b/.env.example index f9fd6db..1b2e62d 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -TOKEN="" \ No newline at end of file +BOT_TOKEN="" \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..09c942a --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,43 @@ +name: Build and publish Docker image + +on: + release: + types: + - published + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + publish-to-registry: + name: 🚀 Publish to registry + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/README.md b/README.md index 5ea1cc4..6ed28ba 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🤖 DDS - Discord Bot -This is a Dutch Drone Squad - Discord bot, that can interact with people in a our Server. +This is a [Dutch Drone Squad][dds] - Discord bot, that can interact with people in a our server. ## Commands @@ -25,11 +25,13 @@ pip3 install -r requirements.txt ```bash docker build -t dds-bot . -docker run -d dds-bot +docker run --name DDS-Bot-Test -d -e TOKEN="[YOUR TOKEN]" dds-bot ``` or ```bash docker-compose up -d -``` \ No newline at end of file +``` + +[dds]: https://dutchdronesquad.nl \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index c4a7e52..ed5c57d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,9 +3,11 @@ version: "3" services: # Discord bot discord-bot: - build: - context: . - dockerfile: Dockerfile + # build: + # context: . + # dockerfile: Dockerfile image: dds-bot:latest container_name: DDS-Bot-Test + environment: + TOKEN: ${BOT_TOKEN} restart: unless-stopped \ No newline at end of file diff --git a/main.py b/main.py index f5782ad..6bed5b6 100644 --- a/main.py +++ b/main.py @@ -77,4 +77,4 @@ async def on_message(message): await bot.process_commands(message) # run the bot using the token in .env -bot.run(os.getenv('TOKEN')) \ No newline at end of file +bot.run(os.environ['TOKEN']) \ No newline at end of file