在 GitHub 操作中检索已修改文件的列表

wha*_*his 4 github github-actions

我是 GitHub 操作的新手,目前正在使用https://github.com/foo-software/lighthouse-check-action来自动完成审计。但是由于urls必须进行硬编码,因此当只想审计提交中修改过的页面并基于这些页面失败时,它并不能证明有用。

如果我完全遗漏了某些东西,有没有办法实现上述目标?我正在查看一些类似https://github.com/marketplace/actions/get-changed-files 的操作,但我无法让它工作。我还查看了 GitHub 事件和参考文档,但无法弄清楚这些。有人会指出我正确的方向吗?

预先感谢您的帮助!

rei*_*eim 8

在尝试使用上面的两个插件和其他一些插件均未成功后,我采取了以下措施:

- uses: actions/checkout@v2
  with:
    fetch-depth: 0
- name: (CI) Dependencies update check
  run: |
    current_commit=`git log -n 1 --pretty=format:%H`
    echo $current_commit
    last_deps_mod_commit=`git log -n 1 --pretty=format:%H -- composer.json`
    echo $last_deps_mod_commit
    if [ $current_commit == $last_deps_mod_commit ]; then echo USE_LOCK=0 > ci.conf; else echo USE_LOCK=1 > ci.conf; fi
Run Code Online (Sandbox Code Playgroud)

请注意,它必须是完整的检出(深度 0)而不是平面检出,否则它将始终返回 true。


fab*_*oad 6

由于错误,lots0logs/gh-action-get-changed-files操作在 atm 中被破坏。看看jitterbit/get-changed-files操作。它非常适合我:

.github/workflows/test.yml

name: Test

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2.1.0
      - uses: jitterbit/get-changed-files@v1
        id: abc
        with:
          format: space-delimited
          token: ${{ secrets.GITHUB_TOKEN }}
      - name: Printing
        run: |
          echo "All:"
          echo "${{ steps.abc.outputs.all }}"
          echo "Added:"
          echo "${{ steps.abc.outputs.added }}"
          echo "Removed:"
          echo "${{ steps.abc.outputs.removed }}"
          echo "Renamed:"
          echo "${{ steps.abc.outputs.renamed }}"
          echo "Modified:"
          echo "${{ steps.abc.outputs.modified }}"
          echo "Added+Modified:"
          echo "${{ steps.abc.outputs.added_modified }}"
Run Code Online (Sandbox Code Playgroud)

日志输出:

2020-05-15T13:47:15.5267496Z All:
2020-05-15T13:47:15.5268424Z .github/workflows/test.yml .tidy-renamed2 Test.ts hello.py
2020-05-15T13:47:15.5268537Z Added:
2020-05-15T13:47:15.5268609Z hello.py
2020-05-15T13:47:15.5268697Z Removed:
2020-05-15T13:47:15.5268787Z Test.ts
2020-05-15T13:47:15.5268880Z Renamed:
2020-05-15T13:47:15.5269260Z .tidy-renamed2
2020-05-15T13:47:15.5269357Z Modified:
2020-05-15T13:47:15.5269450Z .github/workflows/test.yml
2020-05-15T13:47:15.5269547Z Added+Modified:
2020-05-15T13:47:15.5269625Z .github/workflows/test.yml hello.py
2020-05-15T13:47:15.5306656Z Post job cleanup.
Run Code Online (Sandbox Code Playgroud)