Home > Software engineering >  Automatically reject PRs that update certain files
Automatically reject PRs that update certain files

Time:10-16

I use a combination of GitHub Actions and GitHub Pages to generate and host a number of "semi-static" sites. That is sites that are updated regularly during the day using scheduled GitHub Actions. Here's one example.

The repos contain the HTML pages which make up the site, but those pages are all generated by GitHub Actions. There's no point in updating those files in a pull request as the changes will be overwritten the next time the site is regenerated.

I mention this in the README for the repos, but I still get PRs from people that change the output files, rather than the templates that are used to build the files.

To make my life that little easier, I'm wondering if there's a way to mark these files so that any PR that changes these files is automatically rejected with a polite comment explaining the problem. Alternatively, is there a way to mark these files so that GitHub knows they shouldn't be included in PRs?

CodePudding user response:

It's an interesting idea so I tried and it worked!

name: Test workflow

on:
  pull_request_target:
    types: [opened, reopened]
    paths:
      - 'untouchable_file'

jobs:
  test:
    runs-on: "ubuntu-latest"
    steps:
      - uses: superbrothers/close-pull-request@v3
        with:
          comment: "hi. please do not touch 'untouchable_file'."
  • Related