在Github动作中获取分支提交内容

问题描述 投票:0回答:1

给定一个拉取请求的Github Action,我想获得该PR分支的所有提交列表。我可以这样做 git log master.. 但在Action中却失败了。

steps: 
  - uses: actions/checkout@v2
    with:
      ref: ${{ github.event.pull_request.head.sha }}
      fetch-depth: 0
  - run: git log ${{ github.event.pull_request.base.ref }}..

fatal: bad revision 'master'

有什么提示为什么会失败?

continuous-integration pull-request github-actions
1个回答
0
投票

这个动作漏掉了一个 git fetch. 然后可以用 origin/ 前缀。

steps: 
  - uses: actions/checkout@v2
    with:
      ref: ${{ github.event.pull_request.head.sha }}
      fetch-depth: 0
  - run: git fetch
  - run: git log origin/${{ github.event.pull_request.base.ref }}..
© www.soinside.com 2019 - 2024. All rights reserved.