Skip to content

Commit c15afdb

Browse files
authored
Merge pull request #457 from con2/develop
Develop
2 parents 6626b01 + a2de97f commit c15afdb

File tree

97 files changed

+7055
-3189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7055
-3189
lines changed

.github/workflows/reminders.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Booking Reminders
2+
3+
on:
4+
schedule:
5+
# Run twice daily to approximate 09:00 Helsinki across DST
6+
# Summer (EEST, UTC+3): 06:00 UTC ≈ 09:00 local
7+
# Winter (EET, UTC+2): 07:00 UTC ≈ 09:00 local
8+
- cron: '0 6 * * *'
9+
- cron: '0 7 * * *'
10+
workflow_dispatch:
11+
inputs:
12+
scope:
13+
description: "Reminder scope (all | due_today | overdue)"
14+
required: false
15+
default: "all"
16+
17+
concurrency:
18+
group: booking-reminders
19+
cancel-in-progress: true
20+
21+
jobs:
22+
trigger:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Compute scope
26+
id: scope
27+
run: |
28+
if [ -n "${{ github.event.inputs.scope }}" ]; then
29+
echo "scope=${{ github.event.inputs.scope }}" >> $GITHUB_OUTPUT
30+
else
31+
echo "scope=all" >> $GITHUB_OUTPUT
32+
fi
33+
34+
- name: Call backend reminders endpoint
35+
env:
36+
CRON_URL: ${{ secrets.CRON_URL }}
37+
CRON_SECRET: ${{ secrets.CRON_SECRET }}
38+
SCOPE: ${{ steps.scope.outputs.scope }}
39+
run: |
40+
if [ -z "$CRON_URL" ] || [ -z "$CRON_SECRET" ]; then
41+
echo "CRON_URL and/or CRON_SECRET are not set as repo secrets" >&2
42+
exit 1
43+
fi
44+
45+
# Build URL with scope param if needed
46+
if echo "$CRON_URL" | grep -q '\\?'; then
47+
URL="$CRON_URL&scope=$SCOPE"
48+
else
49+
URL="$CRON_URL?scope=$SCOPE"
50+
fi
51+
52+
echo "POST $URL"
53+
http_code=$(curl -sS -o response.json -w "%{http_code}" \
54+
-X POST "$URL" \
55+
-H "X-Cron-Secret: $CRON_SECRET" \
56+
-H "Content-Type: application/json" \
57+
--max-time 60)
58+
59+
echo "Status: $http_code"
60+
echo "Response:"
61+
cat response.json || true
62+
63+
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
64+
echo "Request failed with status $http_code" >&2
65+
exit 1
66+
fi
67+
68+
# Optional: fail if sent skyrockets unusually (spam guard)
69+
# jq -e 'if .sent != null and .sent > 500 then false else true end' response.json
70+
# [ $? -ne 0 ] && { echo "Aborting: unusually high send count" >&2; exit 1; }
71+

0 commit comments

Comments
 (0)