Skip to content

Commit bc73259

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

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

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

1616
jobs:
17+
check_commits_count:
18+
name: Check commits count
19+
runs-on: ubuntu-latest
20+
if: |
21+
github.event_name == 'push' &&
22+
github.ref == 'refs/heads/main'
23+
24+
outputs:
25+
total_commits: ${{ steps.get_commit_counts.outputs.total_commits }}
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0 # Fetch all history for all branches and tags
32+
33+
- name: Get commit count
34+
id: get_commit_counts
35+
run: |
36+
total_commits=$(git rev-list --all --count)
37+
echo "Total commits in the repository: $total_commits"
38+
echo "total_commits=$total_commits" >> $GITHUB_OUTPUT
39+
1740
find_exercise:
41+
needs: [check_commits_count]
42+
if: needs.check_commits_count.outputs.total_commits > 1
1843
name: Find Exercise Issue
1944
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.5.0
2045

0 commit comments

Comments
 (0)