Skip to content

Automerge New CDN Files #13

Automerge New CDN Files

Automerge New CDN Files #13

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:
github-token: ${{ secrets.GH_TOKEN }} # Using GH_TOKEN instead of GITHUB_TOKEN
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 { pr_numbers: validPRs.map(pr => pr.number) };
- name: Combine PRs
if: steps.pr_list.outputs.pr_numbers
uses: github/combine-prs@v5.1.0
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/automerge-action@v0.15.6
env:
GH_TOKEN: "${{ secrets.GH_TOKEN }}" # Using GH_TOKEN here as well
with:
merge_method: squash
merge_commit_message: "Automatically merged combined PR adding new .txt files to /cdn"