name: UI Linter on: workflow_run: workflows: ["UI Checker"] types: - completed workflow_dispatch: inputs: commit_message: description: "Commit Message" type: string required: false jobs: check: if: | (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Check if it is a direct push id: check_push run: | if [[ "${{ github.event_name }}" == "workflow_run" ]]; then if [[ "${{ github.event.workflow_run.event }}" == "pull_request" ]]; then echo "PR detected. Exiting." echo "is_pr=True" >> $GITHUB_OUTPUT else echo "Direct push or other event detected. Proceeding..." echo "is_pr=False" >> $GITHUB_OUTPUT fi else echo "Manual trigger detected. Proceeding..." echo "is_pr=False" >> $GITHUB_OUTPUT fi - name: Checkout repository if: steps.check_push.outputs.is_pr != 'True' uses: actions/checkout@v6 with: show-progress: false persist-credentials: false - name: Install pnpm if: steps.check_push.outputs.is_pr != 'True' uses: pnpm/action-setup@v4 with: version: 9 run_install: true package_json_file: ui/package.json - name: Install Node.js if: steps.check_push.outputs.is_pr != 'True' uses: actions/setup-node@v4 with: node-version: 22 cache: "pnpm" cache-dependency-path: ui/pnpm-lock.yaml - run: pnpm format working-directory: ui - run: pnpm lint:fix working-directory: ui - name: Commit changes id: commit_changes if: steps.check_push.outputs.is_pr != 'True' run: | git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add . if git diff-index --quiet HEAD --; then echo "No changes to commit" else commit_msg="${{ github.event.inputs.commit_message }}" if [ -z "$commit_msg" ]; then commit_msg="chore: Auto Templates Optimization" fi git commit -m "$commit_msg" -m "Triggered by ${{github.sha}}" -m "[skip changelog]" git pull origin $(git rev-parse --abbrev-ref HEAD) --unshallow --rebase echo "have_commits=True" >> $GITHUB_OUTPUT fi - name: Push changes if: steps.check_push.outputs.is_pr != 'True' && steps.commit_changes.outputs.have_commits == 'True' && github.repository_owner == 'MAA1999' uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }}