【发布时间】:2020-03-29 12:19:31
【问题描述】:
我正在尝试创建一个 GitHub Actions 工作流,该工作流将收集在上次提交中更改的特定路径,并为每个收集的路径运行一个步骤(如果有)。
目前,在我的工作流程中,我正在创建一个路径数组,但我不确定如何继续我的数组:
name: Test
on:
push
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
# This step will create "an array" of strings, e.g. "path1 path2 path3"
- name: array
id: arr
run: |
arr=()
for i in "$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }})"
do
if [[ $i == *"path1"* ]]; then
arr+=("path1")
fi
if [[ $i == *"path2"* ]]; then
arr+=("path2")
fi
done
echo ::set-output name=arr::${arr[@]}
# How to run this step by iterating the `${{ steps.arr.outputs.arr }}`?
- name: reviewdog-lint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-review
eslint_flags: 'my_project/some_folder/${{ SINGLE_PATH }}/' # `SINGLE_PATH` would be a path from the array
一开始就可能发生这样的事情吗?如果没有,推荐的方法是循环一些值并将它们用作其他工作流程步骤中的参数?
【问题讨论】:
-
也许这是 github.com/marketplace/actions/file-changes-action 获取上次提交中更改的路径的好选择
标签: yaml workflow github-actions