-
Notifications
You must be signed in to change notification settings - Fork 102
41 lines (34 loc) · 1.28 KB
/
73-if-file-exists.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: 73 - Run Step if File Exists
on:
push:
branches:
- main
jobs:
check_file_job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Step to run if file exists
- name: Run if file exists
if: ${{ !cancelled() && hashFiles('test.py') != '' }}
run: |
# Your command to run if the file exists
echo "File exists, running additional steps..."
- name: Force failure
run: exit 1
# Step to run if file does not exist
- name: File does not exist
if: ${{ !cancelled() && !hashFiles('does-not-exist-fail.txt') != ''}}
run: |
# Your command to run if the file does not exist
echo "File does not exist, skipping additional steps..."
echo ${{ hashFiles('does-not-exist-fail.txt') }}
echo ${{ hashFiles('does-not-exist-fail.txt') != '' }}
echo ${{ !hashFiles('does-not-exist-fail.txt') != '' }}
# Step to run if file does not exist
- name: File does not exist (Should never run)
if: ${{ !cancelled() && hashFiles('does-not-exist-fail.txt') != ''}}
run: |
# Your command to run if the file does not exist
echo "File does not exist, skipping additional steps..."