GitHub Action that Merges PRs on Date
A few months back I built a GitHub Action that merges PRs on a specific date. You can find it here: https://github.com/keithweaver/merge-prs-by-date-github-action
You set up a GitHub workflow that runs on a schedule. It queries the GitHub API for pull requests. It checks the title of the PR for a specific date prefix, then determines if that date has passed. For example:
[Dec 12] Add new feature
[December 12] Fix bug
[Jan 5 2024] Update documentation
Dec 12: Add new feature
December 12: Fix bug
Jan 5 2024: Update documentation
Dec 12 / Add new feature
December 12 / Fix bug
Jan 5 2024 / Update documentation
This is really useful for scheduling blog posts or releasing a feature on a specific date. You put the article up as a PR, put the date in the title, then forget about it. It will merge to main, and release, on its own.
Here is an example workflow:
name: Scheduled PR Merge
on:
schedule:
# Run every day at midnight UTC
- cron: "0 0 * * *"
workflow_dispatch: # Allow manual triggering
jobs:
merge-prs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Merge PRs by Date
uses: keithweaver/merge-prs-by-date-github-action@v1.0.5
with:
repo_owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
github_access_token: ${{ secrets.G_ACCESS_TOKEN }} # Secrets cannot start with GITHUB_
You just need to create a personal access token on GitHub with pull_requests: write and contents: read access. Then set that personal access token in G_ACCESS_TOKEN in the repo settings under Secrets. You cannot prefix the secret with GITHUB_.
That is it! If you find it helpful, please star the repo. It lets me know people are still using it.