-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To work for PRs created from forked repos. Fixes: #329
- Loading branch information
1 parent
d7a8245
commit 2d43570
Showing
1 changed file
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,40 @@ | ||
name: Check for unneeded recipe updates | ||
|
||
on: | ||
pull_request: | ||
pull_request_target: | ||
paths: | ||
- 'docs/recipes/**/*.md' | ||
|
||
jobs: | ||
check_updates: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
steps: | ||
# Checkout the base repository (not the fork) to avoid running untrusted code | ||
- name: Checkout base repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.base.ref }} | ||
|
||
- name: Add warning comment to pull request | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const prNumber = context.payload.pull_request?.number; | ||
if (!prNumber) { | ||
throw new Error('No pull request found.'); | ||
} | ||
const output = ` | ||
While we appreciate that you're attempting to improve the docs, please be aware that all files in the \`/docs/recipes\` directory are auto-generated by the [markdown-generator](https://github.com/openrewrite/rewrite-recipe-markdown-generator). | ||
Please make changes to the recipes themselves rather than to these files. When the next release happens, these files will be updated accordingly. | ||
` | ||
`; | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
await github.rest.issues.createComment({ | ||
issue_number: prNumber, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: output | ||
}) | ||
}); |