-
Notifications
You must be signed in to change notification settings - Fork 45
Automatic comment when PR is made to sc_bilara_data #372
Description
Summary
Automatically leave a bot comment (and close?) any PRs to the sc_bilara_data directory
Motivation
-
The
sc_bilara_datadirectory is synchronized with thebilara-datarepo and so PRs should never be made here -
Typos or translation issues in the Bilara texts should be reported on the forum in the Feedback category, particularly in the pinned thread on typos.
- Generally speaking, the respective translator will review and make changes via the Bilara app instead of directly on GitHub.
- See Update mn127_translation-en-sujato.json #363 (comment), Fix typo in sn44.2:17.7 EN Sujato: "bu" -> "by" bilara-data#4739 (comment) et al for the general rationale of keeping these all in one place on the forum
-
There have been several PRs made to this repo and
bilara-datato fix typos or other mistakes, including from myself.1- Currently, those contributors then have to be manually redirected by someone to the forum thread. This means that someone (usually a volunteer) has to notice their issue and comment on it, during which a delay might occur, etc which is not necessarily the most optimal contributor experience (especially if a PR is just left around for months).
To more quickly and efficiently redirect people in a more standardized way, a bot can automatically leave a comment on such PRs and possibly auto-close them too(?).
Credit to @benmneb for the idea in #363 (comment)
Implementation Details
This should be fairly straightforward to implement with GitHub Actions and would be in an isolated YAML file, so it may be suitable for a beginner or new contributor.
Some examples for reference: https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-github-cli, https://github.com/orgs/community/discussions/69944, https://stackoverflow.com/a/64126737/3431180, https://stackoverflow.com/a/69450384/3431180
-
Create a new GitHub Actions (GHA) workflow YAML file, for instance
bilara-pr-comment.yaml- Place it in the
.github/workflows/directory. Create the directories if necessary (mkdir -p .github/workflows/)
- Place it in the
-
See OpenSSF Scorecard for GHA supply chain security practices, particularly Token-Permissions and Pinned-Dependencies.2
-
Add a PR event trigger for the workflow. For example:
name: Comment on Bilara data PRs permissions: contents: read # read-only by default, only add permissions per job (c.f. https://github.com/ossf/scorecard/blob/6197ba36762d21cdd09172a811953114722bfd52/docs/checks.md#token-permissions) on: pull_request: paths: - 'sc_bilara_data/*' # only trigger on PRs to synced Bilara data directory
-
Create a singular job that will make the comment (and close?). For example:
jobs: comment:
-
Add the appropriate permissions for commenting (and closing?). For example:
comment: permissions: pull-requests: write # allow commenting on PRs
-
Skip certain users like
sc-translatatron(and maybe others? likeccronjeandsabbamittawho sometimes make PRs?)comment: # [...] if: github.actor != 'sc-translatatron' # skip bot PRs
-
Add a step to leave a specific comment
- There's several ways of doing this. If you use an action, remember to pin it to a specific SHA as per above
-
Add a step to close the PR(?)
-
A very similar (but slightly different) workflow should be implemented for the
bilara-datarepo as well.
Testing / Verification
Testing locally can be difficult with GitHub Actions -- there's act, but it doesn't handle everything.
I usually test this kind of GHA workflow on my personal fork first. In this case:
- Push the code to
mainon my fork, then write a test PR tosc_bilara_dataon my own fork and see if the comment is correctly made (and closed?). - Then reset
mainon my fork (remove the commit and force push) and create a PR to the root repository from a feature branch as usual, leaving a link to my test PR on my fork as testing evidence3
-
As examples, see Fix typo in sn44.2:17.7 EN Sujato: "bu" -> "by" bilara-data#4739, Fix typo in mn122 comment-en-sujato bilara-data#4618, Fix typo in mn102_translation-en-sujato.json bilara-data#4546, Update mn127_translation-en-sujato.json #363, Fix typo in view description in mn114_comment-en-sujato.json #357, Fix whitespace typo #351, Update mn85_translation-en-sujato.json #343, etc
-
As examples, can see my prior work in Improve OpenSSF Scorecard checks argoproj/argo-workflows#12031, ci: ensure least privilege permissions for GHA tokens argoproj/argo-workflows#12035, ci: pin all GH Actions argoproj/argo-workflows#12619
-
Here's one example of that, although it's not for automated commenting: ci: only run jobs when relevant files have been changed [actions testing PR] agilgur5/argo-workflows#1