mirror of
https://github.com/trueChristian/daily-scripture.git
synced 2024-09-28 08:39:01 +00:00
Adds test option to repo.
This commit is contained in:
parent
e0f9f7bd8d
commit
6fbeffd21e
27
.github/workflows/test.yml
vendored
Normal file
27
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
name: "Test Today's Scripture!"
|
||||||
|
|
||||||
|
on:
|
||||||
|
# so we can manually run a test also
|
||||||
|
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 Repositry
|
||||||
|
run: |
|
||||||
|
/bin/git clone git@github.com:trueChristian/daily-scripture.git daily_scripture
|
||||||
|
- name: Build the Daily Scripture
|
||||||
|
run: |
|
||||||
|
cd daily_scripture
|
||||||
|
/bin/bash ./src/today.sh --dry
|
3
.github/workflows/today.yml
vendored
3
.github/workflows/today.yml
vendored
@ -5,6 +5,9 @@ on:
|
|||||||
schedule:
|
schedule:
|
||||||
- cron: '7 22 * * *'
|
- cron: '7 22 * * *'
|
||||||
|
|
||||||
|
# so we can manually run a test also
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: [ubuntu-20.04]
|
runs-on: [ubuntu-20.04]
|
||||||
|
72
src/today.sh
72
src/today.sh
@ -1,7 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Do some prep work
|
||||||
|
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
|
||||||
|
DRYRUN=0
|
||||||
|
|
||||||
|
# check if we have options
|
||||||
|
while :; do
|
||||||
|
case $1 in
|
||||||
|
--dry)
|
||||||
|
DRYRUN=1
|
||||||
|
;;
|
||||||
|
*) # Default case: No more options, so break out of the loop.
|
||||||
|
break ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
#██████████████████████████████████████████████████████████████ DATE TODAY ███
|
#██████████████████████████████████████████████████████████████ DATE TODAY ███
|
||||||
TODAY=$(date '+%A %d-%B, %Y')
|
# must set the time to Namibian :)
|
||||||
|
TODAY=$(TZ="Africa/Windhoek" date '+%A %d-%B, %Y')
|
||||||
|
|
||||||
#█████████████████████████████████████████████████████████████ SCRIPT PATH ███
|
#█████████████████████████████████████████████████████████████ SCRIPT PATH ███
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
@ -16,26 +42,37 @@ TMP="$DIR/.TMP"
|
|||||||
sort -R -k1 -b "${SORTED}" >"${TMP}"
|
sort -R -k1 -b "${SORTED}" >"${TMP}"
|
||||||
# get the first line
|
# get the first line
|
||||||
VERSE=$(head -n 1 "${TMP}")
|
VERSE=$(head -n 1 "${TMP}")
|
||||||
# remove the verse
|
# test behaviour
|
||||||
sed -i -e '1,1d' "${TMP}"
|
if (("$DRYRUN" == 1)); then
|
||||||
# add to used verses
|
echo "selected: $VERSE"
|
||||||
[ -f "${USED}" ] && echo "$VERSE" >>"${USED}" || echo "$VERSE" >"${USED}"
|
else
|
||||||
|
# remove the verse
|
||||||
|
sed -i -e '1,1d' "${TMP}"
|
||||||
|
# add to used verses
|
||||||
|
[ -f "${USED}" ] && echo "$VERSE" >>"${USED}" || echo "$VERSE" >"${USED}"
|
||||||
|
fi
|
||||||
|
|
||||||
#█████████████████████████████████████████████████████ SIX MONTH RETENTION ███
|
#█████████████████████████████████████████████████████ SIX MONTH RETENTION ███
|
||||||
# count the number of verse in used file
|
# check test behaviour
|
||||||
LINES_NR=$(wc -l <"${USED}")
|
if (("$DRYRUN" == 0)); then
|
||||||
if [ "$LINES_NR" -gt 182 ]; then
|
# count the number of verse in used file
|
||||||
|
LINES_NR=$(wc -l <"${USED}")
|
||||||
|
if [ "$LINES_NR" -gt 182 ]; then
|
||||||
# get the first line
|
# get the first line
|
||||||
VERSE_BACK=$(head -n 1 "${USED}")
|
VERSE_BACK=$(head -n 1 "${USED}")
|
||||||
# remove the verse
|
# remove the verse
|
||||||
sed -i -e '1,1d' "${USED}"
|
sed -i -e '1,1d' "${USED}"
|
||||||
# add add back to the pile
|
# add add back to the pile
|
||||||
echo "$VERSE_BACK" >>"${TMP}"
|
echo "$VERSE_BACK" >>"${TMP}"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#███████████████████████████████████████████████████████████████ SORT BACK ███
|
#███████████████████████████████████████████████████████████████ SORT BACK ███
|
||||||
# store back for next time
|
# check test behaviour
|
||||||
sort -h -b -k1 "${TMP}" >"${SORTED}"
|
if (("$DRYRUN" == 0)); then
|
||||||
|
# store back for next time
|
||||||
|
sort -h -b -k1 "${TMP}" >"${SORTED}"
|
||||||
|
fi
|
||||||
# remove the temp file
|
# remove the temp file
|
||||||
rm -f "${TMP}"
|
rm -f "${TMP}"
|
||||||
|
|
||||||
@ -61,10 +98,17 @@ ${VERSES//$'\n'/ }
|
|||||||
|
|
||||||
#███████████████████████████████████████████████████████████████ SET FILES ███
|
#███████████████████████████████████████████████████████████████ SET FILES ███
|
||||||
|
|
||||||
echo "${HTML}" >README.html
|
# check test behaviour
|
||||||
echo "${MARKDOWN}" >README.md
|
if (("$DRYRUN" == 1)); then
|
||||||
|
echo "${HTML}"
|
||||||
|
echo "----------------------------------------------------"
|
||||||
|
echo "${MARKDOWN}"
|
||||||
|
else
|
||||||
|
echo "${HTML}" >README.html
|
||||||
|
echo "${MARKDOWN}" >README.md
|
||||||
|
|
||||||
git commit -am"${TODAY}"
|
git commit -am"${TODAY}"
|
||||||
git push
|
git push
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user