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
33 changes: 33 additions & 0 deletions .github/workflows/reusable-lint-cs-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
description: "Specify a branch or commit ID"
required: true
type: string
editorconfig-branch:
description: 'Branch where .editorconfig is located. If not specified, ref will be used.'
required: false
type: string
default: ''
files:
description: 'List of file paths to be linted, separated by a comma (`,`), pipe (`|`), or semicolon (`;`).'
required: true
Expand Down Expand Up @@ -46,6 +51,34 @@ jobs:
ref: ${{ inputs.ref }}
fetch-depth: 0

- name: Branch Configuration
id: branch-conf
run: |
if [ -n "${{ inputs.editorconfig-branch }}" ]; then
editorconfig_branch="${{ inputs.editorconfig-branch }}"
else
editorconfig_branch="${{ inputs.ref }}"
fi
echo "editorconfig-branch=${editorconfig_branch#refs/heads/}" >> "$GITHUB_OUTPUT"
echo "Editorconfig Branch: $editorconfig_branch"

- name: Fetch .editorconfig from Default Branch
if: ${{ inputs.ref != steps.branch-conf.outputs.editorconfig-branch }}
run: |
ref="${{ steps.branch-conf.outputs.editorconfig-branch }}"
git fetch origin "$ref"

if git show-ref --verify --quiet refs/heads/"$ref"; then
echo "$ref was recognized as a branch"
git checkout origin/"$ref" -- .editorconfig
elif [[ "$ref" =~ ^[0-9a-f]{7,40}$ ]] && git rev-parse --quiet "$ref"; then
echo "$ref was recognized as a commit id"
git checkout "$ref" -- .editorconfig
else
echo "An invalid reference was specified: $ref"
exit 1
fi

- name: Create Temporary csproj for Analysis
run: |
{
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/reusable-unity-cs-linter-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ on:
type: string
default: '50'

env:
EDITORCONFIG_SAMPLE_URI: 'https://github.com/IShix-g/Unity-GitHubActions/blob/main/.editorconfig'
CONVERT_TO_SARIF_URI: 'https://raw.githubusercontent.com/IShix-g/Unity-GitHubActions/HEAD/.github/scripts/convert_to_sarif.py'

jobs:
branch-conf:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -105,13 +101,6 @@ jobs:
ref: ${{ needs.branch-conf.outputs.head-branch || needs.branch-conf.outputs.base-branch }}
fetch-depth: 0

- name: Fetch .editorconfig from Default Branch
if: ${{ needs.branch-conf.outputs.editorconfig-branch != needs.branch-conf.outputs.head-branch }}
run: |
branch="${{ needs.branch-conf.outputs.editorconfig-branch }}"
git fetch origin "$branch"
git checkout origin/"$branch" -- .editorconfig

- name: Detect Changed C# Files
id: detect-cs-files
run: |
Expand Down
Loading