{"id":15479714,"url":"https://github.com/gr2m/merge-schedule-action","last_synced_at":"2025-05-16T15:09:29.173Z","repository":{"id":36962127,"uuid":"226417590","full_name":"gr2m/merge-schedule-action","owner":"gr2m","description":"GitHub Action to merge pull requests on a scheduled day","archived":false,"fork":false,"pushed_at":"2025-05-03T16:33:15.000Z","size":2510,"stargazers_count":149,"open_issues_count":11,"forks_count":37,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T19:32:07.963Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gr2m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"gr2m"}},"created_at":"2019-12-06T21:52:29.000Z","updated_at":"2025-05-03T16:33:17.000Z","dependencies_parsed_at":"2023-01-17T08:45:31.872Z","dependency_job_id":"ac829c7a-5554-4a33-96be-b1892a50a91f","html_url":"https://github.com/gr2m/merge-schedule-action","commit_stats":{"total_commits":137,"total_committers":14,"mean_commits":9.785714285714286,"dds":0.7518248175182481,"last_synced_commit":"678b3399de95e30d1c7c48b319b3b86b533d2ab9"},"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fmerge-schedule-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fmerge-schedule-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fmerge-schedule-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gr2m%2Fmerge-schedule-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gr2m","download_url":"https://codeload.github.com/gr2m/merge-schedule-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253878831,"owners_count":21977882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T04:24:52.269Z","updated_at":"2025-05-16T15:09:24.164Z","avatar_url":"https://github.com/gr2m.png","language":"TypeScript","funding_links":["https://github.com/sponsors/gr2m"],"categories":[],"sub_categories":[],"readme":"# merge-schedule-action\n\n\u003e GitHub Action to merge pull requests on a scheduled day\n\n## Usage\n\nCreate `.github/workflows/merge-schedule.yml`\n\n```yml\nname: Merge Schedule\n\non:\n  pull_request:\n    types:\n      - opened\n      - edited\n      - synchronize\n  schedule:\n    # https://crontab.guru/every-hour\n    - cron: '0 * * * *'\n\njobs:\n  merge_schedule:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: gr2m/merge-schedule-action@v2\n        with:\n          # Merge method to use. Possible values are merge, squash or\n          # rebase. Default is merge.\n          merge_method: squash\n          # Time zone to use. Default is UTC.\n          time_zone: 'America/Los_Angeles'\n          # Require all pull request statuses to be successful before\n          # merging. Default is `false`.\n          require_statuses_success: 'true'\n          # Label to apply to the pull request if the merge fails. Default is\n          # `automerge-fail`.\n          automerge_fail_label: 'merge-schedule-failed'\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n```\n\nIn your pull requests, add a line to the end of the pull request description looking like this\n\n```\n/schedule 2022-06-08\n```\n\nIf you need a more precise, timezone-safe setting, you can use an `ISO 8601` date string[^1]\n\n```\n/schedule 2022-06-08T09:00:00.000Z\n```\n\n[^1]: The PR is not scheduled at the given specific time, but at the next time that the scheduler is triggered after the scheduled time. Therefore, catching up on any PRs planned that might have been scheduled between schedule runs.\n\nOr if you want to merge the next time the merge action is scheduled via the cron expressions, you can leave the date empty\n\n```\n/schedule\n```\n\nAny string that works with the [`new Date()` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) will work.\n\nTo control at which time of the day you want the pull request to be merged, I recommend adapting the `- cron: ...` setting in the workflow file.\n\nThe action sets a pending commit status if the pull request was recognized as being scheduled.\n\nNote that pull requests from forks are ignored for security reasons.\n\n### Output\n\nScheduled pull requests and merged pull requests are output by this action, available for use in later actions.\n\nThe output is of the form:\n\n```json\n{\n  \"scheduled_pull_requests\": [\n    {\n      \"number\": 1,\n      \"scheduledDate\": \"2022-06-08T00:00:00.000Z\",\n      \"html_url\":\"https://github.com/gr2m/merge-schedule-action/pull/108\",\n      \"ref\":\"2444141aa0c0369b4e97aaa88af2693ed90a43b8\"\n    }\n  ]\n}\n```\n\nExample usage:\n\n```yaml\nname: Merge Schedule\n\non:\n  pull_request:\n    types:\n      - opened\n      - edited\n      - synchronize\n  schedule:\n    # https://crontab.guru/every-hour\n    - cron: '0 * * * *'\n\njobs:\n  merge_schedule:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: gr2m/merge-schedule-action@v2\n        id: merge-schedule\n        with:\n          # Merge method to use. Possible values are merge, squash or\n          # rebase. Default is merge.\n          merge_method: squash\n          # Time zone to use. Default is UTC.\n          time_zone: 'America/Los_Angeles'\n          # Require all pull request statuses to be successful before\n          # merging. Default is `false`.\n          require_statuses_success: 'true'\n          # Label to apply to the pull request if the merge fails. Default is\n          # `automerge-fail`.\n          automerge_fail_label: 'merge-schedule-failed'\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n          \n      - name: Process Scheduled PRs\n        uses: actions/github-script@v6\n        # Only run if there are scheduled pull requests\n        if: ${{ fromJson(steps.merge-schedule.outputs.scheduled_pull_requests)[0] != null }}\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          script: |\n            const pullRequests = JSON.parse(`${{ steps.merge-schedule.outputs.scheduled_pull_requests }}`);\n            const now = new Date();\n            for (const item of pullRequests) {\n              // Fetch the pull request details\n              const { data: pullRequest } = await github.rest.pulls.get({\n                owner: context.repo.owner,\n                repo: context.repo.repo,\n                pull_number: item.number,\n              });\n              // Do something with the pull request\n            }\n\n      - name: Process Merged PRs\n        uses: actions/github-script@v6\n        # Only run if there are merged pull requests\n        if: ${{ fromJson(steps.merge-schedule.outputs.merged_pull_requests)[0] != null }}\n        with:\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          script: |\n            const pullRequests = JSON.parse(`${{ steps.merge-schedule.outputs.merged_pull_requests }}`);\n            const now = new Date();\n            for (const item of pullRequests) {\n              // Fetch the pull request details\n              const { data: pullRequest } = await github.rest.pulls.get({\n                owner: context.repo.owner,\n                repo: context.repo.repo,\n                pull_number: item.number,\n              });\n              // Do something with the pull request\n            }\n```\n\n## Bypassing Repository Rules\nThere may be cases when you need to bypass certain branch protection rules (i.e. when a branch requires PR approvals prior to merging). On those cases, we recommend creating a [Github App](https://docs.github.com/en/apps/creating-github-apps/about-creating-github-apps/about-creating-github-apps) and granting it access. To set that up, do the following:\n\n1. Register a GitHub App and give it `contents:write` and `pull_request:write` permissions and disable webhooks.\n   (If the repository is private, additional permissions `checks: read` and `statuses: read` are required.)\n2. Install the app in your repository.\n3. Use https://github.com/actions/create-github-app-token to create an installation access token for your app.\n4. Use that token to authenticate gr2m/merge-schedule-action.\n5. Add the app to the \"Allow specified actors to bypass required pull requests\" setting.\n\n## License\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fmerge-schedule-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgr2m%2Fmerge-schedule-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgr2m%2Fmerge-schedule-action/lists"}