Reputation: 528
I've created a custom pull request template (following GitHub Docs) in a subfolder of the .github
directory, e.g.:
├── PULL_REQUEST_TEMPLATE
│ └── custom-template.md
└── PULL_REQUEST_TEMPLATE.md
About automation for issues and pull requests with query parameters indicates you can pass the custom template name as a query parameter when creating the pull request, e.g.
You can use the template query parameter to specify a template to automatically fill the issue or pull request body.
I've tried adding "template": "custom-template.md"
as a query string when creating a new pull request but I end up with an empty pull request template. The default template in the .github
directory still works as expected, but I can't figure out how to get the custom template to load via The API.
Upvotes: 5
Views: 1757
Reputation: 21
Recently I also needed that to have localized templates.
Then I created the default one in pt-BR
:
.github/PULL_REQUEST_TEMPLATE.md
Which will be used when creating a new Pull Request.
And the en-US
one:
.github/PULL_REQUEST_TEMPLATE/PULL_REQUEST-en-US.md
Than inside of the pt-BR
I created a link to the second one:
[English (US)](?quick_pull=1&template=PULL_REQUEST-en-US.md)
Assuming it will be accessed from the Pull Request page (/compare/main...new-branch
) it will replace the query parameters.
Reference:
Query parameter | Example |
---|---|
template |
https://github.com/octo-org/octo-repo/compare/main...my-branch?quick_pull=1&template=issue_template.md creates a pull request with a template in the pull request body. The template query parameter works with templates stored in a PULL_REQUEST_TEMPLATE subdirectory within the root, docs/ or .github/ directory in a repository. For more information, see "Using templates to encourage useful issues and pull requests." |
Upvotes: 2