Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
amrwc committed Mar 14, 2021
1 parent 21d0cb3 commit 06e051f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 51 deletions.
65 changes: 14 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GG Bot

[![Docker][github_badge_docker]][github_actions]
[![Unit and Integration Tests][github_badge_unit_integration]][github_actions]
[![Docker][gh_badge_docker]][gh_actions_docker]
[![Unit and Integration Tests][gh_badge_unit_integration]][gh_actions_unit_integration]

Discord bot to play games with.

Expand All @@ -11,42 +11,11 @@ Discord bot to play games with.
- [Database Inspection](./docs/database-inspection.md)
- [Database Migrations](./docs/database-migrations.md)
- [Design Decisions](./docs/design-decisions.md)
- [Setup Instructions](./docs/setup-instructions.md)
- [Supported Games](./docs/supported-games.md)
- [Working with `bin` Scripts](./docs/working-with-bin-scripts.md)

## Setup

### Discord

1. Create a new application on [Discord Developer
Portal][discord_developer_portal].
1. `Bot` settings.
1. Add a bot and customise it.
1. Save the authentication token.
1. `OAuth2` settings.
1. Add a redirect at `http://localhost:5000`.
1. Choose the newly added redirect URL in the `OAuth2 URL Generator`
section.
1. In `scopes` section, tick `bot`.
1. In `bot permissions` section, tick `Administrator`, or choose more
granular permissions.
1. Copy the invitation URL from the bottom of the `scopes` section and
navigate to it in the browser. Sign in to a relevant Discord account
and add the bot to a server.
1. Once the application's database has been provisioned, update the
`DISCORD_AUTH_TOKEN` row to the authentication token.

```postgresql
UPDATE CONFIG SET VALUE = '<auth_token>' WHERE NAME = 'DISCORD_AUTH_TOKEN';
```

### GitHub Workflows

Add `CR_PAT` secret to the repository to be able to sign into container
registry. Read more on this in [GitHub's
documentation][github_auth_container_registry].

### Docker
## Run using Docker

```console
export SPRING_DATASOURCE_URL='jdbc:postgresql://database-container:5432/dbname'
Expand All @@ -64,21 +33,16 @@ export POSTGRES_PASSWORD='SuperuserPassword'
The application is now listening at `http://localhost:8080`. If the `--debug`
option has been used, the debugger is listening on port `8000`.

Defaults such as database and Spring ports, and volume, network, image,
container names can be adjusted inside `./bin/config.ini`.
Configuration, such as network ports, Docker component names (volumes, network,
images, containers), can be adjusted inside
[./bin/config.ini](./bin/config.ini).

#### Clean
### Clean up

```console
./bin/teardown.py [--cache --db --network --tmp]
```

### Change `spring_user` database password

```sql
ALTER USER spring_user WITH PASSWORD '<new_password>';
```

## Test

### Unit tests
Expand All @@ -93,11 +57,10 @@ ALTER USER spring_user WITH PASSWORD '<new_password>';
./bin/integration_tests.py
```

[discord_developer_portal]: https://discord.com/developers/applications
[github_actions]: https://github.com/amrwc/gg-bot/actions
[github_badge_docker]:
https://github.com/amrwc/gg-bot/workflows/Docker/badge.svg
[github_badge_unit_integration]:
[gh_actions_docker]:
https://github.com/amrwc/gg-bot/actions/workflows/docker.yml
[gh_actions_unit_integration]:
https://github.com/amrwc/gg-bot/actions/workflows/unit-and-integration-tests.yml
[gh_badge_docker]: https://github.com/amrwc/gg-bot/workflows/Docker/badge.svg
[gh_badge_unit_integration]:
https://github.com/amrwc/gg-bot/workflows/Unit%20and%20Integration%20Tests/badge.svg
[github_auth_container_registry]:
https://docs.github.com/en/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
43 changes: 43 additions & 0 deletions docs/setup-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Setup Instructions

## Database credentials

Change `spring_user` database password:

```sql
ALTER USER spring_user WITH PASSWORD '<new_password>';
```

## Discord

1. Create a new application on [Discord Developer
Portal][discord_developer_portal].
1. `Bot` settings.
1. Add a bot and customise it.
1. Save the authentication token.
1. `OAuth2` settings.
1. Add a redirect at `http://localhost:5000`.
1. Choose the newly added redirect URL in the `OAuth2 URL Generator`
section.
1. In `scopes` section, tick `bot`.
1. In `bot permissions` section, tick `Administrator`, or choose more
granular permissions.
1. Copy the invitation URL from the bottom of the `scopes` section and
navigate to it in the browser. Sign in to a relevant Discord account
and add the bot to a server.
1. Once the application's database has been provisioned, update the
`DISCORD_AUTH_TOKEN` row to the authentication token.

```postgresql
UPDATE CONFIG SET VALUE = '<auth_token>' WHERE NAME = 'DISCORD_AUTH_TOKEN';
```

## GitHub Workflows

Add `CR_PAT` secret to the repository to be able to sign into container
registry. Read more on this in [GitHub's
documentation][github_auth_container_registry].

[discord_developer_portal]: https://discord.com/developers/applications
[github_auth_container_registry]:
https://docs.github.com/en/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry
5 changes: 5 additions & 0 deletions docs/working-with-bin-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ for var in $(export | grep -E '(POSTGRES|SPRING)' | awk -F'=' '{print $1}'); do
Note that in the above code snippet, `grep`'s use of `-E` flag may not work
outside of macOS.

## More help

Each script supports `--help` option that displays the docstring of the script.
Use that to display all information about the script.

## Warnings/errors

### No Python interpreter configured for the module
Expand Down

0 comments on commit 06e051f

Please sign in to comment.