-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8fca9b
commit 5ed9d8c
Showing
3 changed files
with
98 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |
SSH_PUB: ${{ secrets.SSH_PUB }} | ||
run: | | ||
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" | ||
- name: Clone Master Repositry | ||
- name: Clone Master Repository | ||
run: | | ||
/bin/git clone [email protected]:trueChristian/daily-light.git daily_light | ||
- name: Build the Daily Light | ||
|
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,34 @@ | ||
name: "Load Today's Light Telegram ID!" | ||
|
||
on: | ||
# run once per/day | ||
schedule: | ||
- cron: '35 14 * * *' | ||
- cron: '35 1 * * *' | ||
# so we can manually update | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: [ubuntu-20.04] | ||
steps: | ||
- name: Setup gitHub User Details | ||
env: | ||
GIT_USER: ${{ secrets.GIT_USER }} | ||
GIT_EMAIL: ${{ secrets.GIT_EMAIL }} | ||
GPG_USER: ${{ secrets.GPG_USER }} | ||
GPG_KEY: ${{ secrets.GPG_KEY }} | ||
SSH_KEY: ${{ secrets.SSH_KEY }} | ||
SSH_PUB: ${{ secrets.SSH_PUB }} | ||
run: | | ||
/bin/bash <(/bin/curl -s https://raw.githubusercontent.com/vdm-io/github-user/master/src/setup.sh) --gpg-key "$GPG_KEY" --gpg-user "$GPG_USER" --ssh-key "$SSH_KEY" --ssh-pub "$SSH_PUB" --git-user "$GIT_USER" --git-email "$GIT_EMAIL" | ||
- name: Clone Master Repository | ||
run: | | ||
/bin/git clone [email protected]:trueChristian/daily-light.git daily_light | ||
- name: Build the Daily Scripture Telegram ID | ||
env: | ||
BOT_TOKEN: ${{ secrets.DAILY_LIGHT_BOT_TOKEN }} | ||
CHANNEL_ID: ${{ secrets.TG_DAILY_LIGHT_GROUP_ID }} | ||
run: | | ||
cd daily_light | ||
/bin/bash ./src/telegram.sh |
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,63 @@ | ||
#!/bin/bash | ||
|
||
# Do some prep work | ||
command -v jq >/dev/null 2>&1 || { | ||
echo >&2 "We require jq for this script to run, but it's not installed. Aborting." | ||
exit 1 | ||
} | ||
command -v git >/dev/null 2>&1 || { | ||
echo >&2 "We require git for this script to run, but it's not installed. Aborting." | ||
exit 1 | ||
} | ||
command -v curl >/dev/null 2>&1 || { | ||
echo >&2 "We require curl for this script to run, but it's not installed. Aborting." | ||
exit 1 | ||
} | ||
|
||
# global config options | ||
DRY_RUN=0 | ||
|
||
# check if we have options | ||
while :; do | ||
case $1 in | ||
--dry) | ||
DRY_RUN=1 | ||
;; | ||
*) # Default case: No more options, so break out of the loop. | ||
break ;; | ||
esac | ||
shift | ||
done | ||
|
||
#██████████████████████████████████████████████████████████████ DATE TODAY ███ | ||
# must set the time to Namibian :) | ||
TODAY=$(TZ="Africa/Windhoek" date '+%A %d-%B, %Y') | ||
|
||
BOT_TOKEN="${BOT_TOKEN}" | ||
CHANNEL_ID="${CHANNEL_ID}" | ||
|
||
CHAT_INFO=$(curl -s "https://api.telegram.org/bot${BOT_TOKEN}/getChat?chat_id=${CHANNEL_ID}") | ||
|
||
MESSAGE_ID=$(echo $CHAT_INFO | jq ".result.pinned_message.forward_from_message_id") | ||
TEXT=$(echo $CHAT_INFO | jq ".result.pinned_message.text" | tr -d "\"") | ||
KEYWORD=$(echo -e "$TEXT" | awk 'NR==1 {print $1}' | tr '[:upper:]' '[:lower:]') | ||
|
||
FILE_PATH="${KEYWORD}.tg.id" | ||
|
||
# check test behaviour | ||
if (("$DRY_RUN" == 1)); then | ||
echo "====================================================" | ||
echo "Message ID: ${MESSAGE_ID}" | ||
echo "Keyword: ${KEYWORD}" | ||
echo "====================================================" | ||
elif [ ! -f "${FILE_PATH}" ] || [ "$(cat "${FILE_PATH}")" != "${MESSAGE_ID}" ]; then | ||
# set ID | ||
echo "${MESSAGE_ID}" >"${FILE_PATH}" | ||
|
||
# make sure to add new files and folders | ||
git add . | ||
git commit -am"${TODAY}" | ||
git push | ||
fi | ||
|
||
exit 0 |