This project uses GitHub Actions to fetch data from another repository and notify via Telegram about power outages. Here's how you can fork this project and set it up for your own use:
- Click on the 'Fork' button at the top right of this repository. This will create a copy of this repository in your GitHub account.
- Clone the forked repository to your local machine.
git clone https://github.com/<your-github-username>/<repository-name>.git
- Navigate to the cloned repository.
cd <repository-name>
- Install the required Python packages.
pip install -r requirements.txt
This project uses two GitHub Actions workflows:
fetch_file.yml
: This workflow fetches a file from another repository and commits it to thefetched_files
directory in this repository.notify.yml
: This workflow runs thenotify.py
script which sends a notification about power outages via Telegram.
To configure these workflows, you need to set up the following secrets in your GitHub repository:
GITHUB_TOKEN
: This is a token that GitHub provides to authenticate your GitHub Actions workflows. You don't need to manually set this secret; GitHub automatically creates it for you.BOT_TOKEN
: This is the token of your Telegram bot. You can get this token by creating a new bot on Telegram.CHAT_ID
: This is the ID of the Telegram chat where you want to send the notifications. You can get this ID by sending a message to your Telegram bot and then using the Telegram API to get the update.
To set these secrets:
- Go to the main page of your GitHub repository.
- Click on 'Settings'.
- Click on 'Secrets and variables'.
- Click on the 'Secrets' tab.
- Click on 'New repository secret'.
- Enter the name of the secret and its value, then click on 'Add secret'.
Next is to configure GitHub variables in your repository to monitor for a specific district and locality
LOCALITY
: The area/region/ for which you want to monitor for power cuts.DISTRICT
: The district in which your locality is located. A list of district values can be found below:
{
"DISTRICT": [
"blackriver",
"flacq",
"grandport",
"moka",
"pamplemousses",
"plainewilhems",
"portlouis",
"rivieredurempart",
"savanne",
"rodrigues"
]
}
To set the DISTRICT
and LOCALITY
variables:
- Go to the main page of your GitHub repository.
- Click on 'Settings'.
- Click on 'Secrets and variables'.
- Click on the 'Variables' tab.
- Click on 'New repository variable'.
- Enter the name of the variable and its value, then click on 'Add variable'.
Once you've set up the secrets, the GitHub Actions workflows will automatically run according to their triggers. The fetch_file.yml
workflow runs every hour from 6 through 18, and the notify.yml
workflow runs whenever you push to the main
branch.
You can also manually trigger these workflows:
- Go to the 'Actions' tab in your GitHub repository.
- Click on the workflow you want to run.
- Click on 'Run workflow'.
- Select the branch where you want to run the workflow, then click on 'Run workflow'.
That's it! You've now set up the project to fetch data and send notifications about power outages.