Skip to content

Commit acc42f4

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,28 @@ 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+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
if [ "$(git rev-list --count HEAD)" -eq 1 ]; then
34+
gh run cancel ${{ github.run_id }}
35+
fi
36+
1737
find_exercise:
38+
needs: [stop_if_initial_commit]
1839
name: Find Exercise Issue
1940
uses: skills/exercise-toolkit/.github/workflows/[email protected]
2041

0 commit comments

Comments
 (0)