Skip to content

Commit

Permalink
close #105, #102 (#109)
Browse files Browse the repository at this point in the history
* close #105, #102

* changelog
  • Loading branch information
felix-schott authored Dec 12, 2024
1 parent 438323f commit b621d35
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Calendar Versioning](https://calver.org/) (`YYYY.MM.MICRO-TAG`).

## [v2024.12.1] - 2024-12-12

### Added

- Added field in `AddSessionPopup` for submission notes and optional email address plus backend support for that feature, implemented as comments in migration scripts (PR [#107](https://github.com/felix-schott/jamsessions/pull/107))

### Fixed

- Fixed bug in geocoding module that occured when an address 2nd line was supplied (PR [#106](https://github.com/felix-schott/jamsessions/pull/106))
- Some fixes related to the `migrations-alert.sh` script (PR [#109](https://github.com/felix-schott/jamsessions/pull/109))

## [v2024.12.0] - 2024-12-02

### Changed
Expand Down
9 changes: 3 additions & 6 deletions deploy/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ will write little bash scripts to $directory/migrations that make use the dbcli
Review the script contents and execute run-migrations.sh to apply all changes.
EOF

crontab -l | grep migrations-alert.sh -q &> /dev/null && {
echo "Alerting cron job already installed"
} || {
echo "Installing alerting cron job";
(crontab -l ; echo "0 */2 * * * bash $directory/migrations-alert.sh") | crontab -
}
echo "Installing alerting cron job"
set +eo pipefail
(crontab -l; echo "0 */2 * * * cd $directory && bash $directory/migrations-alert.sh $directory") | sort - | uniq - | crontab -;

echo "Finished installation process - please consult the generated README file for further instructions."
23 changes: 18 additions & 5 deletions deploy/migrations-alert.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,31 @@

set -eo pipefail

# load .env file if it exists
[[ ! -f .env ]] || set -a && source .env && set +a

[[ $1 == "" ]] && echo "Please provide the target directory of the installation as a positional argument." 1>&2 && exit 1;
directory=$1/migrations
directory=$1

[[ $TELEGRAM_TOKEN == "" ]] && echo "Please provide the environment variable TELEGRAM_TOKEN." 1>&2 && exit 1;
[[ $TELEGRAM_CHAT_ID == "" ]] && echo "Please provide the environment variable TELEGRAM_CHAT_ID." 1>&2 && exit 1;

send_alert () {
curl -X POST https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage -d '{"chat_id":'${TELEGRAM_CHAT_ID}',"text":"PENDING MIGRATIONS"}' -H 'Content-Type: application/json'
type=$1
echo "Sending $type alert"
curl -X POST https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage -d '{"chat_id":'${TELEGRAM_CHAT_ID}',"text":"PENDING '$type'"}' -H 'Content-Type: application/json'
}

if [[ -d $directory ]]; then
ls $directory/*.sh &> /dev/null && send_alert &> /dev/null
echo "Inspecting $directory/migrations directory"
if [[ -d "$directory/migrations" ]]; then
ls $directory/migrations/*.sh &> /dev/null && send_alert "MIGRATIONS" &> /dev/null
else
echo "Directory $directory/migrations does not exist" 1>&2 && exit 1
fi

echo "Inspecting $directory/migrations/suggestions directory"
if [[ -d "$directory/migrations/suggestions" ]]; then
ls $directory/migrations/suggestions/*.sh &> /dev/null && send_alert "SUGGESTIONS" &> /dev/null
else
echo "Directory $directory does not exist" 1>&2 && exit 1
echo "Directory $directory/migrations/suggestions does not exist" 1>&2 && exit 1
fi

0 comments on commit b621d35

Please sign in to comment.