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!
- I had to use
pull_request_target
as the event for forked repositories. More information can be found at https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/. - I've picked
opened
andreopened
for the activity types, however please find more from here if you need it: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request - For now, this github action is triggered when the file
untouchable_file
is included as a change in a pull request, but if you need more complex path filter matching, see here: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
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'."