Skip to content

Commit

Permalink
Publish to Github registry (#4)
Browse files Browse the repository at this point in the history
* Update documentation

* Inprove TOKEN usage for docker image

* Add publish workflow

* Update dockerignore
  • Loading branch information
klaasnicolaas committed Oct 18, 2021
1 parent 7a2b357 commit 42ce026
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Files
.env

# Folders
.git
.github
.dockerignore
Dockerfile
venv
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TOKEN=""
BOT_TOKEN=""
43 changes: 43 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
```
```

[dds]: https://dutchdronesquad.nl
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
bot.run(os.environ['TOKEN'])

0 comments on commit 42ce026

Please sign in to comment.