Sync Precommit Config #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Precommit Config | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - ".pre-commit-config.yaml" | |
| - "global/pre-commit.sh" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: true | |
| - name: Ensure target folder exists inside global/ | |
| run: mkdir -p global/precommitFile | |
| - name: Copy updated pre-commit config to global/precommitFile | |
| run: | | |
| cp .pre-commit-config.yaml global/precommitFile/.pre-commit-config.yaml | |
| - name: Check if changes exist | |
| id: changes | |
| run: | | |
| if git diff --quiet global/precommitFile/.pre-commit-config.yaml; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit & push updates | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git add global/precommitFile/.pre-commit-config.yaml | |
| git commit -m "Sync pre-commit YAML config → global/precommitFile" | |
| git push |