-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite reddit bot to be better selfhostable and less prone to being…
… ratelimited
- Loading branch information
Showing
28 changed files
with
1,601 additions
and
915 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.editorconfig | ||
.github/ | ||
.gitignore | ||
README.md | ||
LICENSE | ||
Dockerfile | ||
conf.env | ||
conf.env.example | ||
config.json | ||
config.example.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Binary Release | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goos: [ linux, windows, darwin ] | ||
goarch: [ amd64, 386, arm, arm64 ] | ||
exclude: | ||
- goos: darwin | ||
goarch: 386 | ||
- goos: darwin | ||
goarch: arm | ||
- goos: windows | ||
goarch: arm | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
cache: true | ||
|
||
- name: File Extension Windows | ||
if: ${{ matrix.goos == 'windows' }} | ||
run: echo "file_extension=.exe" >> $GITHUB_ENV | ||
|
||
- name: Prepare Version Info | ||
run: | | ||
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV | ||
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
- name: Build | ||
run: | | ||
CGO_ENABLED=0 | ||
GOOS=${{ matrix.goos }} | ||
GOARCH=${{ matrix.goarch }} | ||
go build -ldflags "-X main.Version=${{ env.VERSION }} -X main.Commit=${{ env.COMMIT }}" -o reddit-discord-bot-${{ matrix.goos }}-${{ matrix.goarch }}${{ env.file_name }} github.com/topi314/reddit-discord-bot | ||
- name: Upload | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: reddit-discord-bot | ||
path: reddit-discord-bot | ||
|
||
- name: Release | ||
if: ${{ github.event_name == 'release' }} | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: reddit-discord-bot-* | ||
allowUpdates: true | ||
omitBodyDuringUpdate: true | ||
omitDraftDuringUpdate: true | ||
omitNameDuringUpdate: true | ||
omitPrereleaseDuringUpdate: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,68 @@ | ||
name: Docker | ||
name: Build and Deploy | ||
|
||
on: | ||
push: | ||
push: | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/topisenpai/reddit-discord-bot | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=sha,prefix= | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=ref,event=branch | ||
type=ref,event=tag | ||
type=ref,event=pr | ||
type=sha,prefix= | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Prepare Version Info | ||
run: | | ||
echo "VERSION=$(git describe --tags)" >> $GITHUB_ENV | ||
echo "COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
- name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm/v7,linux/arm64/v8 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
VERSION=${{ env.VERSION }} | ||
COMMIT=${{ env.COMMIT }} | ||
deploy: | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Deploy | ||
uses: fjogeleit/http-request-action@v1 | ||
with: | ||
url: "https://watchtower.topi.wtf/v1/update?image=ghcr.io/topi314/reddit-discord-bot" | ||
method: "POST" | ||
timeout: 60000 | ||
customHeaders: '{"Authorization": "Bearer ${{ secrets.TOKEN }}"}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.idea/ | ||
|
||
conf.env | ||
.env | ||
config.yml | ||
database.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.