mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-10-06 00:42:03 +00:00
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:
parent
5e052d424d
commit
769b9e5acd
1 changed files with 63 additions and 14 deletions
77
.github/workflows/deploy-notify.yml
vendored
77
.github/workflows/deploy-notify.yml
vendored
|
|
@ -1,8 +1,14 @@
|
||||||
name: Deploy Notification
|
name: Daily Version Bump
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
schedule:
|
||||||
branches: [main]
|
# 6pm ET (EDT = 22:00 UTC, EST = 23:00 UTC)
|
||||||
|
- cron: "0 22 * * *"
|
||||||
|
- cron: "0 23 * * *"
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
notify:
|
notify:
|
||||||
|
|
@ -10,26 +16,69 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
- name: Extract version info from commit
|
- name: DST guard
|
||||||
id: info
|
id: dst
|
||||||
run: |
|
run: |
|
||||||
MSG=$(git log -1 --pretty=%s)
|
HOUR=$(TZ=America/New_York date +%H)
|
||||||
echo "message=$MSG" >> "$GITHUB_OUTPUT"
|
if [ "$HOUR" != "18" ]; then
|
||||||
# Count merge commits on main as version number
|
echo "ET hour is $HOUR, not 18 — wrong DST rule fired"
|
||||||
COUNT=$(git rev-list --count HEAD)
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
echo "count=$COUNT" >> "$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
|
- name: Post to Slack
|
||||||
|
if: steps.dst.outputs.skip != 'true' && steps.changes.outputs.has_changes == 'true'
|
||||||
env:
|
env:
|
||||||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
|
||||||
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
|
SLACK_CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
|
||||||
|
VERSION: ${{ steps.changes.outputs.version }}
|
||||||
|
BULLETS: ${{ steps.changes.outputs.bullets }}
|
||||||
run: |
|
run: |
|
||||||
|
TEXT=$(printf ":rocket: *%s deployed*\n\n%s" "$VERSION" "$BULLETS")
|
||||||
curl -s -X POST https://slack.com/api/chat.postMessage \
|
curl -s -X POST https://slack.com/api/chat.postMessage \
|
||||||
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
|
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$(jq -n \
|
-d "$(jq -n --arg channel "$SLACK_CHANNEL_ID" --arg text "$TEXT" \
|
||||||
--arg channel "$SLACK_CHANNEL_ID" \
|
|
||||||
--arg text ":rocket: *Deployed to production* — ${{ steps.info.outputs.message }}" \
|
|
||||||
'{channel: $channel, text: $text}')"
|
'{channel: $channel, text: $text}')"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue