mirror of
https://github.com/captainark/github2email.git
synced 2024-11-13 05:07:39 +01:00
initial commit
This commit is contained in:
commit
05bb181348
29
README.md
Normal file
29
README.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Github2eMail
|
||||
|
||||
## What is it ?
|
||||
|
||||
Github2eMail is a bash script that parses the GitHub API for projects you've starred and adds them to your rss2email configuration.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [curl](https://github.com/curl/curl)
|
||||
- [rss2email](https://github.com/wking/rss2email)
|
||||
- [jq](https://github.com/stedolan/jq)
|
||||
|
||||
## How do I use it ?
|
||||
|
||||
You need to have installed and configured rss2email first.
|
||||
|
||||
Clone this repo.
|
||||
|
||||
Edit the `config` file and modify the `UserName` variable to your GitHub username.
|
||||
|
||||
Run the script.
|
||||
|
||||
You're done !
|
||||
|
||||
You can also run the script periodically from cron if you want.
|
||||
|
||||
## TODO
|
||||
|
||||
Remove projects that were added by the script and are no longer starred by the user on GitHub from rss2email configuration.
|
2
config
Normal file
2
config
Normal file
@ -0,0 +1,2 @@
|
||||
# Set this to your GitHub User Name
|
||||
UserName="changemeplease"
|
40
github2email.sh
Normal file
40
github2email.sh
Normal file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# shellcheck source=config
|
||||
source "$(dirname $0)/config"
|
||||
|
||||
# Checking if UserName has been defined
|
||||
if [[ -z ${UserName} ]] || [[ $UserName == "changemeplease" ]]; then
|
||||
echo "GitHub username is incorrect of undefined in config file. Exiting..."
|
||||
fi
|
||||
|
||||
GitHubApi="https://api.github.com/users/${UserName}/starred"
|
||||
StarredList=$(curl -s ${GitHubApi} | jq -r '.[] | .name + "," + .html_url' | sed 's#$#/releases.atom#')
|
||||
|
||||
# Checking for API request success
|
||||
if [[ -z ${StarredList} ]]; then
|
||||
echo "Something went wrong while fetching the project starred list for ${UserName}. Exiting..."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Checking for dependencies
|
||||
for Dependencies in curl jq r2e; do
|
||||
if [[ ! -x $(which ${Dependencies}) ]]; then
|
||||
echo "${Dependencies} is required to run to script. Exiting..."
|
||||
exit 2
|
||||
fi
|
||||
done
|
||||
|
||||
# Doing our magic stuff that does cool shit
|
||||
for Star in ${StarredList}; do
|
||||
ProjectName=${Star%,*}
|
||||
ProjectUrl=${Star##*,}
|
||||
# Only add a project to r2e config if it does not already exist
|
||||
IsDeclaredProject="$(r2e list | grep ${ProjectUrl})"
|
||||
if [[ -z ${IsDeclaredProject} ]]; then
|
||||
r2e add ${ProjectName} ${ProjectUrl}
|
||||
# We only want to be informed of future releases
|
||||
r2e run --no-send ${ProjectName}
|
||||
echo "Project ${ProjectName} has been added to rss2email configuration !"
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user