diff --git a/.github/workflows/lint-unity-cs-dispatch.yaml b/.github/workflows/lint-unity-cs-dispatch.yaml index 023407b3..6d52cb17 100644 --- a/.github/workflows/lint-unity-cs-dispatch.yaml +++ b/.github/workflows/lint-unity-cs-dispatch.yaml @@ -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 diff --git a/.github/workflows/reusable-check-editorconfig.yaml b/.github/workflows/reusable-check-editorconfig.yaml index 5060a90a..6f49dc54 100644 --- a/.github/workflows/reusable-check-editorconfig.yaml +++ b/.github/workflows/reusable-check-editorconfig.yaml @@ -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 \ No newline at end of file