Overview
You want to run a step in your pipeline, only if a certain file exists
Details
- Clone your repository
- After the clone step, check for existence of file.
- If it exists, set your Variable to true. Otherwise, set it to false.
- In the appropriate step, check whether the variable is true or not.
steps:
main_clone:
type: git-clone
description: Cloning main repository...
repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
revision: '${{CF_REVISION}}'
checkFile:
image: alpine
commands:
- if [ -f README.md ]; then cf_export fileExists=true; else cf_export fileExists=false; fi
confirmFile:
image: alpine
commands:
- echo $fileExists
when:
condition:
all:
fileExists: '"${{fileExists}}" == "true"'
Note:
You can use this to also check if a file is missing, or to perform similar more complicated checks and create a flow for your pipelines.