diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3b93e30175..0b1f308ce3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,4 +21,30 @@ jobs: - name: Install project dependencies run: yarn install - name: Lint + id: lint run: yarn nx format:check --all + continue-on-error: true # Continue even if the check fails + + - name: Check Lint Results + if: steps.lint.outcome == 'failure' + run: echo "lint_failed=true" >> $GITHUB_OUTPUT + + - name: Auto-format and commit changes if needed + if: steps.lint.outcome == 'failure' + run: | + yarn nx format:write --all + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + git add . + git commit -m "auto fmt" || echo "No changes to commit" + + # Get the current branch name + BRANCH_NAME=$(git symbolic-ref --short HEAD || git rev-parse --abbrev-ref HEAD) + + # If we're in detached HEAD state, use the GitHub event information + if [ "$BRANCH_NAME" = "HEAD" ]; then + BRANCH_NAME=${{ github.head_ref || github.ref_name }} + fi + + # Push changes + git push origin HEAD:$BRANCH_NAME || echo "No changes to push"