Skip to content

Commit c074ced

Browse files
authored
feat: Prevent running on initial commit
1 parent f375e4c commit c074ced

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/workflows/1-first-codespace.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,26 @@ env:
1414
STEP_2_FILE: ".github/steps/2-custom-image.md"
1515

1616
jobs:
17+
stop_if_initial_commit:
18+
name: Stop workflow if initial commit
19+
runs-on: ubuntu-latest
20+
if: |
21+
github.event_name == 'push' &&
22+
github.ref == 'refs/heads/main' &&
23+
startsWith(github.event.head_commit.message, 'Initial commit')
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Cancel workflow if there is only 1 commit in history
30+
run: |
31+
if [ "$(git rev-list --count HEAD)" -eq 1 ]; then
32+
gh run cancel ${{ github.run_id }}
33+
fi
34+
1735
find_exercise:
36+
needs: [stop_if_initial_commit]
1837
name: Find Exercise Issue
1938
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
2039

0 commit comments

Comments
 (0)