且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Git Push上创建请求请求

更新时间:2022-06-25 05:08:09

如果您查看

If you look at the documentation of the create-pull-request action, it mentions that

创建请求请求"操作将:

Create Pull Request action will:

  • 在动作"工作空间中检查存储库更改.这包括:
    • 未跟踪的(新)文件
    • 跟踪(已修改)的文件
    • 工作流中尚未推送的承诺
    • Check for repository changes in the Actions workspace. This includes:
      • untracked (new) files
      • tracked (modified) files
      • commits made during the workflow that have not been pushed

      它总是需要一个中间分支来提交更改.

      It would always need an intermediary branch where it can commit the changes.

      因此,如果您按以下方式修改工作流配置,请添加Reset master branch步骤以从远程develop分支获取最新更改并重置master分支,并为操作(工作流)指定branch: temp会创建一个temp分支,其提交与您推送到develop分支的提交相同,并打开从tempmaster分支的PR.在随后的开发承诺中,它将继续对temp分支进行相同的更改,并类似地打开PR或更新现有PR.

      So if you modify your workflow config as below, adding the Reset master branch step to get the latest changes from the remote develop branch and reset the master branch, and specify branch: temp for the action, the workflow would create a temp branch with the same commits that you have pushed to develop branch and open a PR from temp to master branch. In subsequent commits to develop, it would keep on making the same changes to temp branch and open a PR similarly or update the existing PR.

      name: Create pull request
      on:
        push:
          branches:
            - develop
      jobs:
        prForMasterBranch:
          runs-on: ubuntu-latest
          steps:
            - uses: actions/checkout@v2
              with:
                ref: master
            - name: Reset master branch
              run: |
                git fetch origin develop:develop
                git reset --hard develop
            - name: Create Pull Request
              uses: peter-evans/create-pull-request@v2
              with:
                commit-message: update master branch
                title: Update master branch
                branch: temp
      

      请注意,temp分支将具有推送到develop分支的确切提交.

      Note that the temp branch will have the exact commits that are pushed to the develop branch.