根据另一个任务中定义的变量值跳过 Github 操作中的任务
Skip a task in Github action based on the value of a variable defined in another task
在 Github 操作中,我有一个任务执行一些检查并输出一个布尔标志作为结果。如果标志为 False,我想跳过其他任务。我不确定语法,以下内容无法按预期工作。
name: test
jobs:
test_job:
name: Test
runs-on: ubuntu-20.04
steps:
- name: Create flag
id: create_flag
run: |
# run some checks and put results in FLAG
# and make that available to other tasks.
# "true" for true, and "false" for false (so string instead of boolean).
echo "::set-output name=FLAG::$FLAG"
- name: Run-me if FLAG is true
if: ${{ steps.create_flag.outputs.FLAG }} == "true"
run: |
# some logic to run if flag==true
您需要将 'true' 放在单引号中。
检查与转化相关的 GitHub 表达式部分 here
if: ${{ steps.create_flag.outputs.FLAG == 'true' }}
if: steps.create_flag.outputs.FLAG == 'true'
这是您的工作流程的示例 运行:
https://github.com/grzegorzkrukowski/Whosebug_tests/runs/5558400970?check_suite_focus=true
以及工作流程的来源:
https://github.com/grzegorzkrukowski/Whosebug_tests/actions/runs/1988349309/workflow
在 Github 操作中,我有一个任务执行一些检查并输出一个布尔标志作为结果。如果标志为 False,我想跳过其他任务。我不确定语法,以下内容无法按预期工作。
name: test
jobs:
test_job:
name: Test
runs-on: ubuntu-20.04
steps:
- name: Create flag
id: create_flag
run: |
# run some checks and put results in FLAG
# and make that available to other tasks.
# "true" for true, and "false" for false (so string instead of boolean).
echo "::set-output name=FLAG::$FLAG"
- name: Run-me if FLAG is true
if: ${{ steps.create_flag.outputs.FLAG }} == "true"
run: |
# some logic to run if flag==true
您需要将 'true' 放在单引号中。
检查与转化相关的 GitHub 表达式部分 here
if: ${{ steps.create_flag.outputs.FLAG == 'true' }}
if: steps.create_flag.outputs.FLAG == 'true'
这是您的工作流程的示例 运行:
https://github.com/grzegorzkrukowski/Whosebug_tests/runs/5558400970?check_suite_focus=true
以及工作流程的来源:
https://github.com/grzegorzkrukowski/Whosebug_tests/actions/runs/1988349309/workflow