【问题标题】:Retrieving list of modified files in GitHub action在 GitHub 操作中检索已修改文件的列表
【发布时间】:2020-04-04 22:09:20
【问题描述】:
【问题讨论】:
标签:
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。