Skip to content

Commit

Permalink
build: Working workflow with versioning and replacing deployed contai…
Browse files Browse the repository at this point in the history
…ners
  • Loading branch information
lcox74 committed Apr 5, 2024
1 parent d4a6cf3 commit 51cdb8a
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
jobs:

build:
runs-on: ubuntu-latest
runs-on: self-hosted
permissions:
contents: read
packages: write
Expand Down
42 changes: 40 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,39 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: aussiebroadwan/tony
CONTAINER_NAME: tab-tony

jobs:

build:
runs-on: self-hosted
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Login to the Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Build and push Docker image with Buildx
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}
deploy:
runs-on: deploy
steps:
Expand All @@ -22,7 +52,15 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Pull the Docker image
- name: Pull ${{ github.ref_name}}
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}

# Stop the existing container
- name: Stop Existing Container
run: docker stop ${{ env.CONTAINER_NAME }} || true

# Deploy the Docker image
- name: Deploy Latest
run: docker run -d -e DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} -e DISCORD_SERVER_ID=${{ secrets.DISCORD_SERVER_ID }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Deploy ${{ github.ref_name}}
run: docker run --name=${{ env.CONTAINER_NAME }} -d -e DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }} -e DISCORD_SERVER_ID=${{ secrets.DISCORD_SERVER_ID }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name}}
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ go build .
./tony
```

> **Note:** Future development will move the program into a Docker container for
> easier deploying, but this is just a rush job to get a basic bot up
> and running.

### Running as a Container

You will be able to get

## Current Bot Features

There are only two main commands currently with Tony, the rest are application
rules that run on either specific channels or on all.

- `ping`:
Sends the user a `Pong @<user>!` message. This is only for testing.

Expand All @@ -51,17 +55,22 @@ go build .
- `del <id>`: Deletes a message, assuming the user owns the message
- `status <id>`: Get how much time is left on a reminder
- `list`: List the ID and times of all the user's reminders

- `tech-news` [**MODERATION**]:
A system to ensure posts being made in the `#tech-news` channel is in a
specific format.

- `rss` [**MODERATION**]:
A system to ensure posts being made in the `#rss` channel is in a specifc
format.
The following here are Application rules and not commands. This means they run
on all messages limited to their registered channels, with the exception of
`autopin` which is registered for all channels.

- `tech-news`:
A moderation system to ensure posts being made in the `#tech-news` channel
is in a specific format.

- `rss`:
A moderation system to ensure posts being made in the `#rss` channel is in
a specifc format.

- `autopin` [**REACTION**]:
A system which automatically pins messages if there are 5 or more 📌 reacts.
- `autopin`:
A reaction system which automatically pins messages if there are 5 or
more 📌 reacts.

[Go]: https://go.dev/
[App Commands]: https://discord.com/developers/docs/interactions/application-commands
Expand Down

0 comments on commit 51cdb8a

Please sign in to comment.