-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2594 from alphagov/copy-pr-template-to-dependabot…
…-prs Create workflow to copy PR template onto Dependabot PRs
- Loading branch information
Showing
1 changed file
with
28 additions
and
9 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,22 +1,41 @@ | ||
name: Copy PR template to Dependabot PRs | ||
|
||
on: | ||
pull_request_target: | ||
types: [opened] | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: | ||
copy_pr_template: | ||
name: Copy PR template to Dependabot PR | ||
runs-on: ubuntu-latest | ||
if: github.actor == 'dependabot[bot]' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Fetch PR template | ||
id: fetch-pr-template | ||
uses: juliangruber/read-file-action@v1 | ||
- name: Post PR template as a comment | ||
uses: actions/github-script@v6 | ||
with: | ||
path: .github/pull_request_template.md | ||
script: | | ||
const fs = require('fs') | ||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
issue-number: ${{ github.event.number }} | ||
body: ${{ steps.fetch-pr-template.outputs.content }} | ||
const body = [ | ||
"pull_request_template.md", | ||
".github/pull_request_template.md", | ||
"docs/pull_request_template.md", | ||
]. | ||
filter(path => fs.existsSync(path)). | ||
map(path => fs.readFileSync(path)). | ||
join("\n") | ||
if (body !== "") { | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body | ||
}) | ||
} |