mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 16:03:12 +00:00
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.
84 lines
2.8 KiB
YAML
84 lines
2.8 KiB
YAML
name: Daily Version Bump
|
|
|
|
on:
|
|
schedule:
|
|
# 6pm ET (EDT = 22:00 UTC, EST = 23:00 UTC)
|
|
- cron: "0 22 * * *"
|
|
- cron: "0 23 * * *"
|
|
workflow_dispatch: {}
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
notify:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
fetch-tags: true
|
|
|
|
- name: DST guard
|
|
id: dst
|
|
run: |
|
|
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 "$TEXT" \
|
|
'{channel: $channel, text: $text}')"
|