Skip to content

Combine and Automerge PRs #4

Combine and Automerge PRs

Combine and Automerge PRs #4

Workflow file for this run

name: Combine and Automerge PRs
on:
workflow_dispatch: # Allows manual triggering of the workflow
permissions:
contents: write
pull-requests: write
checks: read
jobs:
combine-and-automerge:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: List Pull Requests Ready for Batch Merge
id: pr_list
uses: actions/github-script@v6
with:
script: |
const { data: pullRequests } = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
sort: 'updated',
direction: 'desc',
});
// Filter PRs that add a single .txt file in the /cdn directory
const validPRs = pullRequests.filter(pr => {
return pr.files_url && pr.files.length === 1 && pr.files[0].filename.match(/^cdn\/.*\.txt$/);
});
return validPRs.map(pr => pr.number);
- name: Combine PRs
if: steps.pr_list.outputs.pr_numbers
uses: github/[email protected]
with:
base: 'main' # Specify the base branch for the combined PR
head: 'combined-prs' # The new branch for the combined PR
title: 'Combined PRs adding .txt files to /cdn'
body: 'This PR combines all PRs that add .txt files to the /cdn directory.'
- name: Automerge Combined PR
if: success()
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
merge_method: squash
merge_commit_message: "Automatically merged combined PR adding new .txt files to /cdn"