Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions .github/workflows/auto-merge-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ name: auto-merge-release

on:
schedule:
# 10:00 UTC = 4am CST (winter) / 5am CDT (summer)
- cron: "0 10 * * 1"
- cron: "0 10 * * *"
workflow_dispatch:

permissions: {}
Expand All @@ -17,10 +16,32 @@ jobs:
if: github.repository == 'jdx/usage'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
Comment thread
cursor[bot] marked this conversation as resolved.
- name: Merge release into main
run: |
set -euo pipefail

latest_tag=$(git tag --list 'v[0-9]*' --sort=-v:refname | head -1 || true)
if [ -n "$latest_tag" ]; then
range="${latest_tag}..HEAD"
tag_time=$(git log -1 --format=%ct "$latest_tag")
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
now=$(date +%s)
min_age=$((7 * 24 * 60 * 60))
age=$((now - tag_time))
if [ "$age" -lt "$min_age" ]; then
echo "Latest release ${latest_tag} is less than 7 days old; not auto-merging release PRs"
exit 0
fi
else
range="HEAD"
fi
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Outdated
if ! git log --format=%s "$range" | grep -Eq '^(fix|feat)(\([^)]+\))?!?: '; then
Comment thread
cursor[bot] marked this conversation as resolved.
Outdated
echo "No pending fix/feat commits since the latest release; not auto-merging release PRs"
exit 0
fi

PR_NUMBER=$(gh pr list -R jdx/usage --base main --head release --state open --limit 100 --json number,headRefName,headRepositoryOwner \
--jq '[.[] | select(.headRefName == "release") | select(.headRepositoryOwner.login == "jdx")][0].number // empty')
if [ -z "$PR_NUMBER" ]; then
Expand All @@ -35,7 +56,7 @@ jobs:
exit 0
fi

echo "PR #$PR_NUMBER is ready for the Monday morning release window"
echo "PR #$PR_NUMBER is ready for the daily release window"
gh pr merge "$PR_NUMBER" -R jdx/usage --squash --auto
env:
GH_TOKEN: ${{ secrets.MY_RELEASE_PLEASE_TOKEN }}
Loading