如何获取通过GitHub Action中的commit更新的文件的文件名? [英] How to get file names of files updated by commit in GitHub Actions?

查看:351
本文介绍了如何获取通过GitHub Action中的commit更新的文件的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在GitHub Actions工作流中,我们多次尝试使用此命令run: git diff-tree --no-commit-id --name-only -r ${{ github.sha }}获取通过推送提交更改的文件的文件名.但是它始终仅返回以下日志,不提供文件名或带路径的文件名.请参见下图.

关于跑步者类型:ubuntu-latest,它不是自托管跑步者.

解决方案

默认情况下,checkout操作会创建浅表克隆.使用

  - uses: actions/checkout@v2
    with:
      # Number of commits to fetch. 0 indicates all history for all branches and tags.
      # Default: 1
      fetch-depth: 2

来源: https://github.com/actions/checkout#usage

In a GitHub Actions workflow, we tried multiple times to get the file names of the files changed by the pushed commit with this command run: git diff-tree --no-commit-id --name-only -r ${{ github.sha }}. But it always returns only the following log not giving a file name or a file name with path. See the below image.

About Runner type: ubuntu-latest, which is not a self-hosted runner.

解决方案

The checkout action creates a shallow clone by default. Use

  - uses: actions/checkout@v2
    with:
      # Number of commits to fetch. 0 indicates all history for all branches and tags.
      # Default: 1
      fetch-depth: 2

source: https://github.com/actions/checkout#usage

这篇关于如何获取通过GitHub Action中的commit更新的文件的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆