|
1 | | -name: Sync Pre-commit Config |
| 1 | +name: Sync Precommit Config |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | paths: |
8 | 8 | - ".pre-commit-config.yaml" |
9 | | - - "precommitFile/**" |
| 9 | + - "global/pre-commit.sh" |
10 | 10 | workflow_dispatch: |
11 | 11 |
|
12 | 12 | permissions: |
13 | 13 | contents: write |
14 | 14 |
|
15 | 15 | jobs: |
16 | | - sync-config: |
| 16 | + sync: |
17 | 17 | runs-on: ubuntu-latest |
18 | 18 |
|
19 | 19 | steps: |
20 | 20 | - name: Checkout repository |
21 | 21 | uses: actions/checkout@v4 |
22 | 22 | with: |
23 | | - fetch-depth: 0 |
| 23 | + fetch-depth: 0 |
| 24 | + persist-credentials: true |
24 | 25 |
|
25 | | - - name: Ensure precommitFile directory exists |
26 | | - run: mkdir -p precommitFile |
| 26 | + - name: Ensure target folder exists inside global/ |
| 27 | + run: mkdir -p global/precommitFile |
27 | 28 |
|
28 | | - - name: Copy .pre-commit-config.yaml to precommitFile directory |
29 | | - run: cp .pre-commit-config.yaml precommitFile/.pre-commit-config.yaml |
| 29 | + - name: Copy updated pre-commit config to global/precommitFile |
| 30 | + run: | |
| 31 | + cp .pre-commit-config.yaml global/precommitFile/.pre-commit-config.yaml |
30 | 32 |
|
31 | | - - name: Check for changes |
32 | | - id: git_status |
| 33 | + - name: Check if changes exist |
| 34 | + id: changes |
33 | 35 | run: | |
34 | | - if git diff --quiet; then |
| 36 | + if git diff --quiet global/precommitFile/.pre-commit-config.yaml; then |
35 | 37 | echo "changed=false" >> $GITHUB_OUTPUT |
36 | 38 | else |
37 | 39 | echo "changed=true" >> $GITHUB_OUTPUT |
38 | 40 | fi |
39 | 41 |
|
40 | | - - name: Commit and push changes |
41 | | - if: steps.git_status.outputs.changed == 'true' |
| 42 | + - name: Commit & push updates |
| 43 | + if: steps.changes.outputs.changed == 'true' |
42 | 44 | run: | |
43 | 45 | git config user.name "GitHub Actions" |
44 | 46 | git config user.email "actions@github.com" |
45 | | -
|
46 | | - git add precommitFile/.pre-commit-config.yaml |
47 | | - git commit -m "Sync .pre-commit-config.yaml to precommitFile directory" |
| 47 | + |
| 48 | + git add global/precommitFile/.pre-commit-config.yaml |
| 49 | + git commit -m "Sync pre-commit YAML config → global/precommitFile" |
48 | 50 | git push |
0 commit comments