Skip to content

Commit 9be06e5

Browse files
committed
fix: dont't guess. Just do it.
1 parent db208d6 commit 9be06e5

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ outputs:
77
primaryLanguage:
88
description: 'Detected primary language for the repository'
99
runs:
10-
using: 'node20'
11-
main: 'dist/index.js'
10+
using: 'composite'
11+
steps:
12+
- run: bash ${{ github.action_path }}/src/get-primary-language.sh
13+
shell: bash
1214

1315
branding:
1416
icon: 'flag'

src/get-primary-language.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Get the repository root directory
6+
REPO_ROOT="${GITHUB_WORKSPACE:-.}"
7+
8+
# Check for Go indicators
9+
if [[ -f "$REPO_ROOT/.goreleaser" ]] || [[ -f "$REPO_ROOT/go.mod" ]]; then
10+
echo "primary_language=Go" >> "$GITHUB_OUTPUT"
11+
echo "Detected primary language: Go"
12+
exit 0
13+
fi
14+
15+
# Check for C# indicators
16+
if [[ -f "$REPO_ROOT/.sln" ]]; then
17+
echo "primary_language='C#'" >> "$GITHUB_OUTPUT"
18+
echo "Detected primary language: C#"
19+
exit 0
20+
fi
21+
22+
# Check for .csproj files within one level deep
23+
if find "$REPO_ROOT" -maxdepth 2 -name "*.csproj" -type f | grep -q .; then
24+
echo "primary_language='C#'" >> "$GITHUB_OUTPUT"
25+
echo "Detected primary language: C#"
26+
exit 0
27+
fi
28+
29+
# No primary language detected
30+
echo "primary_language=Unknown" >> "$GITHUB_OUTPUT"
31+
echo "No primary language detected"

0 commit comments

Comments
 (0)