diff --git a/.github/workflows/gobo_check.yml b/.github/workflows/gobo_check.yml index 590250908..9e6885b8b 100644 --- a/.github/workflows/gobo_check.yml +++ b/.github/workflows/gobo_check.yml @@ -1,4 +1,4 @@ -name: Format Code +name: GoboLintCheck on: pull_request: @@ -31,8 +31,10 @@ jobs: - name: Run Formatter if: steps.changed-files.outputs.any_changed == 'true' run: | - # Pass all changed files to gobo at once - ./gobo ${{ steps.changed-files.outputs.all_changed_files }} + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + echo "Formatting $file..." + ./gobo "$file" + done - name: Verify Formatting run: | diff --git a/.github/workflows/gobo_lint.yml b/.github/workflows/gobo_lint.yml new file mode 100644 index 000000000..355c798d9 --- /dev/null +++ b/.github/workflows/gobo_lint.yml @@ -0,0 +1,62 @@ +name: GoboLint + +on: + issue_comment: + types: [created] + +jobs: + lint: + if: > + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/lint') && + (github.event.comment.author_association == 'COLLABORATOR' || + github.event.comment.author_association == 'MEMBER' || + github.event.comment.author_association == 'OWNER') + + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Get PR branch + uses: xt0rted/pull-request-comment-branch@v2 + id: comment-branch + + - name: Checkout PR branch + uses: actions/checkout@v4 + with: + ref: ${{ steps.comment-branch.outputs.head_ref }} + repository: ${{ steps.comment-branch.outputs.head_owner }}/${{ steps.comment-branch.outputs.head_repo }} + fetch-depth: 0 + + - name: Get Changed Files + id: changed-files + uses: tj-actions/changed-files@v44 + with: + base_sha: ${{ steps.comment-branch.outputs.base_ref }} + files: '**.gml' + + - name: Setup Gobo + if: steps.changed-files.outputs.any_changed == 'true' + run: | + curl -LO https://github.com/EttyKitty/Gobo/releases/download/v1.0.0/gobo-ubuntu.zip + unzip gobo-ubuntu.zip + chmod +x ./gobo + + - name: Run Linter + if: steps.changed-files.outputs.any_changed == 'true' + run: | + for file in ${{ steps.changed-files.outputs.all_changed_files }}; do + if [ -f "$file" ]; then + echo "Linting $file..." + ./gobo "$file" + fi + done + + - name: Commit Changes + if: steps.changed-files.outputs.any_changed == 'true' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "style: auto-lint GML files with Gobo" + file_pattern: '**.gml' \ No newline at end of file