【问题标题】:Retrieving list of modified files in GitHub action在 GitHub 操作中检索已修改文件的列表
【发布时间】:2020-04-04 22:09:20
【问题描述】:

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

如果我完全错过了什么,有没有办法实现上述目标?我正在查看https://github.com/marketplace/actions/get-changed-files 之类的一些操作,但我无法让它发挥作用。我还查看了 GitHub 事件和参考文档,但无法弄清楚这些内容。有人会指出我正确的方向吗?

提前感谢您的帮助!

【问题讨论】:

    标签: github github-actions


    【解决方案1】:

    lots0logs/gh-action-get-changed-files 操作因this 错误而损坏 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 }}"
    

    日志输出:

    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.
    

    【讨论】:

    【解决方案2】:

    在尝试使用上述两个插件均不成功后,我采取了以下措施:

    - 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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-09
      • 1970-01-01
      • 2021-07-15
      • 2021-06-29
      • 1970-01-01
      • 2013-12-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多