Skip to content

Commit

Permalink
Merge pull request #4 from RAHB-REALTORS-Association/1.1.0
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
justinh-rahb authored Sep 29, 2023
2 parents ad18f67 + fccec32 commit bf06ea8
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:

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

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: Docker Image

on:
push:
branches:
- master
paths:
- '**.py'
- 'requirements.txt'
create:

env:
Expand All @@ -15,7 +9,7 @@ env:

jobs:
build-and-push-image:
if: github.event_name == 'push' || (github.event_name == 'create' && startsWith(github.ref, 'refs/tags/'))
if: github.event.ref_type == 'tag' # This job runs only if the created object is a tag
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -53,4 +47,4 @@ jobs:
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -48,4 +48,4 @@ jobs:
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
40 changes: 40 additions & 0 deletions .github/workflows/rcn-roster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: RCN Roster

on:
workflow_dispatch:
schedule:
- cron: '0 16 15 * *' # Runs at 16:00 UTC on the 15th of every month

jobs:
generate-rcn-report:
runs-on: ubuntu-latest

env:
REDASH_URL: ${{ secrets.REDASH_URL }} # Base Redash URL
API_KEY: ${{ secrets.REDASH_API_KEY }} # RCN API key
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
FROM_EMAIL: ${{ secrets.RCN_FROM_EMAIL }}
TO_EMAILS: ${{ secrets.RCN_TO_EMAILS }}
# Non-sensitive information can be set directly
QUERY_IDS: "15" # RCN Active Members
TITLES: "RCN Active Members"
LOGO_URL: "https://s1.cdn.rahb.ca/rahbca/wp-content/uploads/2018/10/RAHB-logo_hztrans_video.png"
TIMESTAMP_FORMAT: "%Y-%m-%d"
SUBJECT: "RAHB Active RCN members list for {{time_period}}"
CONTENT: "Enclosed active RAHB RCN members spreadsheet of {{time_period}} for your reference."
DAY_OF_MONTH: "15"
HOUR_OF_DAY: "12" # 12:00 UTC is 8:00 EDT

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run RCN Report
run: python main.py --now
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 📊 CSV to XLSX Report Generator 📈
# 📊 Redash XLSX Reports 📈

[![Continuous Integration](https://github.com/RAHB-REALTORS-Association/redash-report/actions/workflows/python-app.yml/badge.svg)](https://github.com/RAHB-REALTORS-Association/redash-report/actions/workflows/python-app.yml)
[![Docker Image](https://github.com/RAHB-REALTORS-Association/redash-report/actions/workflows/docker-image.yml/badge.svg)](https://github.com/RAHB-REALTORS-Association/redash-report/actions/workflows/docker-image.yml)
Expand All @@ -10,6 +10,7 @@ This project generates an XLSX report from CSV data obtained from Redash queries
- [✅ Requirements](#-requirements)
- [🛠️ Configuration](#configuration)
- [🧑‍💻 Usage](#-usage)
- [🐳 Running with Docker](#-running-with-docker)
- [🌐 Community](#-community)
- [Contributing 👥](#contributing-)
- [Reporting Bugs 🐛](#reporting-bugs-)
Expand Down Expand Up @@ -48,6 +49,26 @@ python main.py --now

The script will run indefinitely in the absence of the `--now` argument, generating and emailing a report according to the schedule specified in `settings.py`.

## 🐳 Running with Docker

To get started, you first need to pull the Docker image from the GitHub Container Registry. You can do this by running the following command in your terminal:

```bash
docker pull ghcr.io/rahb-realtors-association/redash-report:latest
```

Set environment variables as needed and run with the following command:

```bash
docker run ghcr.io/rahb-realtors-association/redash-report:latest
```

Alternatively, download the `settings.example.py` and save it as `settings.py`. Modify as needed and run with the following command:

```bash
docker run -v /path/to/your/settings.py:/app/settings.py ghcr.io/rahb-realtors-association/redash-report:latest
```

## 🌐 Community

### Contributing 👥
Expand Down
22 changes: 22 additions & 0 deletions settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import os

# Redash settings
redash_url = os.environ.get('REDASH_URL', "https://www.example.com/redash")
api_key = os.environ.get('API_KEY', "your_redash_api_key")
query_ids = os.environ.get('QUERY_IDS', "1,2,3").split(',') # Converts "1,2,3" to [1, 2, 3]
query_ids = [int(qid) for qid in query_ids] # Convert string IDs to integers
titles = os.environ.get('TITLES', "Title 1,Title 2,Title 3").split(',') # Converts "Title 1,Title 2,Title 3" to ['Title 1', 'Title 2', 'Title 3']

logo_url = os.environ.get('LOGO_URL', "https://www.example.com/logo.png")
timestamp_format = os.environ.get('TIMESTAMP_FORMAT', "%Y-%m-%d")

# Email settings
sendgrid_api_key = os.environ.get('SENDGRID_API_KEY', "your_sendgrid_api_key")
from_email = os.environ.get('FROM_EMAIL', "[email protected]")
to_emails = os.environ.get('TO_EMAILS', "[email protected],[email protected]").split(',') # Converts "[email protected],[email protected]" to ['[email protected]', '[email protected]']
subject = os.environ.get('SUBJECT', "Summary Report for {{time_period}}")
content = os.environ.get('CONTENT', "Please find attached the latest summary report for {{time_period}}.")

# Schedule settings
day_of_month = int(os.environ.get('DAY_OF_MONTH', 15)) # Convert string to integer
hour_of_day = int(os.environ.get('HOUR_OF_DAY', 16)) # Convert string to integer

0 comments on commit bf06ea8

Please sign in to comment.