Change deploy notifications to daily version bumps (#24)

Replaces per-push notifications with a daily 6pm ET cron job that
batches all commits since the last version tag into a single Slack
message. Tags main with a date-based version (v2026.05.01) so there
is at most one version bump per day. Includes DST guard matching the
pattern used by the other scheduled Lambdas.
This commit is contained in:
Adam Moussa 2026-05-01 14:37:54 -04:00 • committed by GitHub
parent 5e052d424d
commit 769b9e5acd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,8 +1,14 @@
name: Deploy Notification
name: Daily Version Bump
on:
push:
branches: [main]
schedule:
# 6pm ET (EDT = 22:00 UTC, EST = 23:00 UTC)
- cron: "0 22 * * *"
- cron: "0 23 * * *"
workflow_dispatch: {}
permissions:
contents: write
jobs:
notify:
@ -10,26 +16,69 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
fetch-depth: 0
fetch-tags: true
- name: Extract version info from commit
id: info
- name: DST guard
id: dst
run: |
MSG=$(git log -1 --pretty=%s)
echo "message=$MSG" >> "$GITHUB_OUTPUT"
# Count merge commits on main as version number
COUNT=$(git rev-list --count HEAD)
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
HOUR=$(TZ=America/New_York date +%H)
if [ "$HOUR" != "18" ]; then
echo "ET hour is $HOUR, not 18 — wrong DST rule fired"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Check for changes since last version tag
if: steps.dst.outputs.skip != 'true'
id: changes
run: |
LAST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -1)
if [ -z "$LAST_TAG" ]; then
echo "No previous version tag — using full history"
COMMITS=$(git log --oneline --pretty=format:"%s")
else
COMMITS=$(git log "$LAST_TAG"..HEAD --oneline --pretty=format:"%s")
fi
if [ -z "$COMMITS" ]; then
echo "No new commits since $LAST_TAG"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "has_changes=true" >> "$GITHUB_OUTPUT"
# Build bullet list from commit messages, skip merge commits
BULLET_LIST=$(echo "$COMMITS" | grep -v "^Merge" | sed 's/^/• /')
{
echo "bullets<<ENDOFBULLETS"
echo "$BULLET_LIST"
echo "ENDOFBULLETS"
} >> "$GITHUB_OUTPUT"
# Date-based version
VERSION="v$(date +%Y.%m.%d)"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create version tag
if: steps.dst.outputs.skip != 'true' && steps.changes.outputs.has_changes == 'true'
run: |
git tag ${{ steps.changes.outputs.version }}
git push origin ${{ steps.changes.outputs.version }}
- name: Post to Slack
if: steps.dst.outputs.skip != 'true' && steps.changes.outputs.has_changes == 'true'
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
VERSION: ${{ steps.changes.outputs.version }}
BULLETS: ${{ steps.changes.outputs.bullets }}
run: |
TEXT=$(printf ":rocket: *%s deployed*\n\n%s" "$VERSION" "$BULLETS")
curl -s -X POST https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d "$(jq -n \
--arg channel "$SLACK_CHANNEL_ID" \
--arg text ":rocket: *Deployed to production* — ${{ steps.info.outputs.message }}" \
-d "$(jq -n --arg channel "$SLACK_CHANNEL_ID" --arg text "$TEXT" \
'{channel: $channel, text: $text}')"