|
6 | 6 | workflow_dispatch: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - lint: |
10 | | - if: github.repository_owner == 'TYPO3-documentation' |
11 | | - runs-on: ubuntu-latest |
12 | | - permissions: |
13 | | - contents: write # needed to push commit |
14 | | - steps: |
15 | | - - name: Checkout code |
16 | | - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
17 | | - with: |
18 | | - token: ${{ secrets.GITHUB_TOKEN }} |
19 | | - |
20 | | - - name: Set up Python |
21 | | - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 |
22 | | - with: |
23 | | - python-version: '3.x' |
24 | | - |
25 | | - - name: Install pre-commit |
26 | | - run: pip install pre-commit |
27 | | - |
28 | | - - name: Run pre-commit hooks and apply fixes |
29 | | - id: pre-commit |
30 | | - run: | |
31 | | - # Run pre-commit with auto-fix and ignore exit code |
32 | | - pre-commit run --all-files --hook-stage=manual --show-diff-on-failure || true |
33 | | - # Check if any files were modified |
34 | | - git diff --exit-code || echo "FIX_NEEDED=true" >> $GITHUB_ENV |
35 | | - env: |
36 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
37 | | - |
38 | | - - name: Check for existing PR |
39 | | - if: env.FIX_NEEDED == 'true' |
40 | | - id: check_pr |
41 | | - run: | |
42 | | - EXISTING_PR=$(gh pr list --state open --search "Fix whitespace issues" --json number -q '.[].number') |
43 | | - if [[ -n "$EXISTING_PR" ]]; then |
44 | | - echo "EXISTING_PR=true" >> $GITHUB_ENV |
45 | | - fi |
46 | | - env: |
47 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
48 | | - |
49 | | - - name: Create and push changes if needed |
50 | | - if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true' |
51 | | - id: create_branch |
52 | | - run: | |
53 | | - git config user.name "github-actions[bot]" |
54 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
55 | | - # Create a new branch for the changes |
56 | | - BRANCH_NAME="fix/whitespace-$(date +'%Y%m%d%H%M%S')" |
57 | | - git checkout -b "$BRANCH_NAME" |
58 | | - git add . |
59 | | - git commit -m "fix: apply whitespace fixes" |
60 | | - git push origin "$BRANCH_NAME" |
61 | | - echo "branch_name=$BRANCH_NAME" >> $GITHUB_ENV |
62 | | - env: |
63 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
64 | | - |
65 | | - - name: Open Pull Request |
66 | | - if: env.FIX_NEEDED == 'true' && env.EXISTING_PR != 'true' |
67 | | - uses: repo-sync/pull-request@7e79a9f5dc3ad0ce53138f01df2fad14a04831c5 |
68 | | - with: |
69 | | - source_branch: ${{ env.branch_name }} |
70 | | - destination_branch: ${{ github.ref_name }} |
71 | | - pr_title: "Fix whitespace issues" |
72 | | - pr_body: "This PR automatically applies whitespace fixes." |
73 | | - token: ${{ secrets.GITHUB_TOKEN }} |
| 9 | + precommit: |
| 10 | + uses: TYPO3-Documentation/.github/.github/workflows/reusable-apply-precommit.yml@main |
0 commit comments