Skip to content

Commit f74c893

Browse files
committed
add conditional workflow
1 parent 6445b8d commit f74c893

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: 'conditional-fail'
2+
3+
on:
4+
pull_request:
5+
branches: [ 'dont_run_me' ]
6+
7+
jobs:
8+
fail_on_commit_message:
9+
runs-on: 'ubuntu-latest'
10+
steps:
11+
- name: 'Checkout code'
12+
uses: 'actions/checkout@v4'
13+
14+
- name: 'Check for "fail" in commit message'
15+
id: 'check_commit'
16+
run: |
17+
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
18+
if echo "$COMMIT_MESSAGE" | grep -qi "fail"; then
19+
echo "found_fail=true" >> "$GITHUB_OUTPUT"
20+
fi
21+
22+
- name: 'Fail Step'
23+
if: steps.check_commit.outputs.found_fail == 'true'
24+
run: |
25+
echo 'Failing because "fail" was found in the commit message.'
26+
exit 1
27+

0 commit comments

Comments
 (0)