Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/lint-unity-cs-dispatch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ on:
type: string
default: ''

permissions:
checks: write

jobs:
unity-cs-linter:
uses: IShix-g/Unity-GitHubActions/.github/workflows/reusable-unity-cs-linter-dispatch.yaml@main
Expand Down
59 changes: 18 additions & 41 deletions .github/workflows/reusable-check-editorconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,52 +33,29 @@ jobs:
outputs:
exists: ${{ steps.check-editorconfig.outputs.exists }}
steps:
- name: Check out ${{ inputs.ref }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
fetch-depth: 1

- name: Check for .editorconfig
id: check-editorconfig
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
file_path=".editorconfig"
ref="${{ inputs.ref }}"
max_retries="${{ inputs.max-retries }}"
retry_delay_sec="${{ inputs.retry-delay }}"
fail_on_missing="${{ inputs.fail-on-missing }}"
echo "Checking .editorconfig in ref: $ref"

echo "Checking for file: $file_path in the checked-out repository..."

success=false

for ((i=1; i<=max_retries; i++)); do
response=$(timeout 10s gh api "repos/${{ github.repository }}/contents/$file_path?ref=$ref" \
--header "Authorization: Bearer $GH_TOKEN" \
--jq ". | select(.type==\"file\") | select(.name==\"$file_path\")")

api_exit_code=$?

if [ $api_exit_code -eq 124 ]; then
echo "::warning::Attempt $i: API request timed out. Retrying in $retry_delay_sec seconds..."
sleep $retry_delay_sec
continue
elif [ -z "$response" ]; then
if [ $i -eq $max_retries ]; then
if [ "$fail_on_missing" = "true" ]; then
echo "::error::Failed to find .editorconfig after $max_retries retries in ref '$ref'."
else
echo "::warning::Failed to find .editorconfig after $max_retries retries in ref '$ref'. Not failing workflow."
fi
else
echo "::warning::Attempt $i: .editorconfig file not found. Retrying in $retry_delay_sec seconds..."
sleep $retry_delay_sec
fi
else
echo "::notice::Success: .editorconfig file exists in ref '$ref'."
success=true
break
if [ -f "$file_path" ]; then
echo "::notice::.editorconfig file exists."
success=true
else
echo "::warning::.editorconfig file does not exist."
if [ "$fail_on_missing" = "true" ]; then
exit 1
fi
done
fi

echo "exists=$success" | tee -a "$GITHUB_OUTPUT"

if [ "$success" = "false" ] && [ "$fail_on_missing" = "true" ]; then
exit 1
fi
Loading