-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JeffP07/main
Update Bot
- Loading branch information
Showing
6 changed files
with
99 additions
and
8 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CLIENT_ID='' # Reddit application client ID | ||
CLIENT_SECRET='' # Reddit application client secret | ||
USERNAME='' # Bot's Reddit username | ||
PASSWORD='' # Bot's Reddit password | ||
WHITELIST='' # List of Reddit usernames to sticky posts. Format: ["Username1", "Username2"] | ||
SUBREDDIT='' # Subreddit to watch for posts. Do not include the /r/ |
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,52 @@ | ||
name: Docker Image CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
# Use docker.io for Docker Hub if empty | ||
REGISTRY: ghcr.io | ||
# github.repository as <account>/<repo> | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: replace_envs | ||
uses: franzbischoff/replace_envs@v2 | ||
env: | ||
CLIENT_ID: ${{ secrets.CLIENT_ID }} | ||
CLIENT_SECRET: ${{ secrets.API_KEY }} | ||
USERNAME: ${{ secrets.USERNAME }} | ||
PASSWORD: ${{ secrets.PASSWORD }} | ||
WHITELIST: ${{ secrets.WHITELIST }} | ||
SUBREDDIT: ${{ secrets.SUBREDDIT }} | ||
- name: Docker Metadata action | ||
id: meta | ||
uses: docker/metadata-action@v5.5.1 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=sha | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} |
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,12 @@ | ||
FROM python:3.11.8-alpine | ||
|
||
# Copy requirements and install into image | ||
COPY requirements.txt . | ||
RUN pip install --no-cache-dir --upgrade -r requirements.txt | ||
|
||
# Copy project into image | ||
COPY . /app | ||
WORKDIR /app | ||
|
||
# Run bot.py | ||
CMD ["python", "-u", "bot.py"] |
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,10 @@ | ||
# Environment Variables | ||
|
||
### Set these environment variables by either editing the .env file before building the Docker image or adding them in the Docker container's settings | ||
|
||
- CLIENT_ID `# Reddit application client ID` | ||
- CLIENT_SECRET `# Reddit application client secret` | ||
- USERNAME `# Bot's Reddit username` | ||
- PASSWORD `# Bot's Reddit password` | ||
- WHITELIST `# List of Reddit usernames that will have their posts stickied. Format: ["Username1", "Username2"]` | ||
- SUBREDDIT `# Subreddit to watch for posts. Do not include the r/` |
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,2 @@ | ||
python-dotenv | ||
praw |