Files
rfd-notify/README.md
2023-12-09 00:26:31 -05:00

149 lines
3.8 KiB
Markdown

# rfd-notify
This tool looks for matches on [RedFlagDeals.com forums](https://forums.redflagdeals.com/hot-deals-f9/) and will send push notifications via [apprise](https://github.com/caronc/apprise).
This was originally written before [alerts](https://www.redflagdeals.com/alerts/) existed. With rfd-notify, alerts never expire and support regular expressions.
## Prerequisites
- either [poetry](https://github.com/python-poetry/poetry), docker, or github actions
- a free [SendGrid API key](https://sendgrid.com/pricing/) is suggested for email notifications
## Usage
The simplest way to get started is to clone this repo, and run with docker:
```sh
docker run -it -v "$(pwd)/examples/config.yml:/app/config.yml" ghcr.io/davegallant/rfd-notify:1
```
To run the code with [poetry](https://python-poetry.org/), clone this repo and run the following:
```shell
poetry install
poetry run python rfd_notify/cli.py -c examples/config.yml
```
### Environment Variables
The following environment variables are required:
| VARIABLE | DESCRIPTION |
| ----------- | ---------------------------------------------------------------- |
| APPRISE_URL | See [notifications](https://github.com/caronc/apprise#productivity-based-notifications). |
## Example Configuration
Pass a list of expressions to be used for discovering deals:
```yaml
# config.yml
expressions:
- pizza
- starbucks
- price error
```
## Github Actions
An action can be setup to scan for deals, send a notification and store previously found deals in the repo.
It also requires the corresponding [encrypted secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets) setup.
```yaml
# .github/workflows/rfd-notify.yml
on:
push:
schedule:
- cron: "*5 * * * *"
jobs:
rfd_notify:
name: rfd-notify
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/cache@v3
id: cache
with:
path: previous_matches
key: previous_matches
- name: Run rfd-notify
uses: davegallant/rfd-notify@main
env:
APPRISE_URL: ${{ secrets.APPRISE_URL }}
```
## Gitlab Pipelines
> Create a [scheduled pipeline](https://docs.gitlab.com/ee/ci/pipelines/schedules.html) to run on a regular interval.
With Gitlab Pipelines, the following configuration works:
```yaml
#.gitlab-ci.yml
default:
image:
name: ghcr.io/davegallant/rfd-notify:1
entrypoint: [""]
run:
cache:
- key: previous_matches
paths:
- previous_matches
script:
- python /app/rfd_notify/cli.py -c config.yml
```
## Jenkins
> The necessary Jenkins plugins (such as docker) and credentials must be configured.
Using a declarative pipeline, run the build every minute, and store the previous matches in the workspace:
```groovy
pipeline {
agent any
triggers {
cron('* * * * *')
}
options {
buildDiscarder(
logRotator(
numToKeepStr: '25',
artifactNumToKeepStr: '25'
)
)
disableConcurrentBuilds()
}
stages {
stage('Run rfd-notify') {
agent {
docker {
image 'ghcr.io/davegallant/rfd-notify:1'
args '--entrypoint='
reuseNode true
}
}
steps {
withCredentials([string(credentialsId: 'apprise-url', variable: 'APPRISE_URL')]) {
sh 'python /app/rfd_notify/cli.py -c config.yml'
}
}
}
stage('Archive previous_matches') {
steps {
archiveArtifacts artifacts: 'previous_matches'
}
}
}
}
```