[英]github action to create a branch and pull request
What would be a good way to do the following in github actions:在 github 操作中执行以下操作的好方法是什么:
Should I use raw git commands?我应该使用原始 git 命令吗? Or the github cli?
还是 github cli? Or other actions?
还是其他动作?
What would you suggest?你有什么建议?
I've used Create Pull Request GHA ( https://github.com/peter-evans/create-pull-request ) and it is quite easy to use.我使用了 Create Pull Request GHA ( https://github.com/peter-evans/create-pull-request ),它非常易于使用。 Within the action itself you can even specify the branch name.
在操作本身中,您甚至可以指定分支名称。 In the next step, you can also run shell commands.
在下一步中,您还可以运行 shell 命令。 Example as below:
示例如下:
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v3
- name: Check outputs
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
I was looking for a solution that didn't require using actions from a third-party and figured out that Github actions now support Github command line natively, if you use Github hosted runners.我正在寻找一种不需要使用第三方操作的解决方案,并发现 Github 操作现在支持Github 命令行,如果您使用 Github 托管的跑步者。 See: Using Github CLI in Workflows
请参阅: 在工作流中使用 Github CLI
This makes it super easy to create a pull request using the gh pr create command.这使得使用gh pr create命令创建拉取请求变得非常容易。
Something like this:像这样的东西:
steps
- name: create pull request
run: gh pr create -B base_branch -H branch_to_merge --title 'Merge branch_to_merge into base_branch' --body 'Created by Github action'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.