|
1 | 1 | name: Update CLI Docs |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | | - paths: |
7 | | - - 'tests/main/**' |
8 | | - - 'tests/test_main_kr.py' |
9 | | - - 'src/datamodel_code_generator/arguments.py' |
10 | | - - 'src/datamodel_code_generator/cli_options.py' |
11 | | - - 'scripts/build_cli_docs.py' |
12 | | - - 'scripts/build_prompt_data.py' |
13 | 4 | pull_request: |
14 | 5 | branches: [main] |
15 | 6 | paths: |
|
19 | 10 | - 'src/datamodel_code_generator/cli_options.py' |
20 | 11 | - 'scripts/build_cli_docs.py' |
21 | 12 | - 'scripts/build_prompt_data.py' |
22 | | - pull_request_target: |
23 | | - types: [labeled] |
24 | | - paths: |
25 | | - - 'tests/main/**' |
26 | | - - 'tests/test_main_kr.py' |
27 | | - - 'src/datamodel_code_generator/arguments.py' |
28 | | - - 'src/datamodel_code_generator/cli_options.py' |
29 | | - - 'scripts/build_cli_docs.py' |
30 | | - - 'scripts/build_prompt_data.py' |
| 13 | + - 'docs/cli-reference/**' |
| 14 | + - 'src/datamodel_code_generator/prompt_data.py' |
31 | 15 |
|
32 | 16 | permissions: |
33 | | - contents: write |
| 17 | + contents: read |
34 | 18 |
|
35 | 19 | jobs: |
36 | 20 | update-cli-docs: |
37 | | - if: | |
38 | | - github.event_name == 'push' || |
39 | | - !github.event.pull_request.head.repo.fork || |
40 | | - github.actor == 'koxudaxi' || |
41 | | - github.actor == 'gaborbernat' || |
42 | | - github.actor == 'ilovelinux' || |
43 | | - (github.event_name == 'pull_request_target' && github.event.label.name == 'safe-to-fix' && |
44 | | - (github.event.sender.login == 'koxudaxi' || |
45 | | - github.event.sender.login == 'gaborbernat' || |
46 | | - github.event.sender.login == 'ilovelinux')) |
47 | 21 | runs-on: ubuntu-latest |
48 | 22 | steps: |
49 | | - # Checkout for forks (no PAT available) |
50 | | - - uses: actions/checkout@v4 |
51 | | - if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository |
| 23 | + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
52 | 24 | with: |
53 | 25 | fetch-depth: 0 |
54 | | - ref: ${{ github.event.pull_request.head.ref }} |
| 26 | + ref: ${{ github.event.pull_request.head.sha }} |
55 | 27 | repository: ${{ github.event.pull_request.head.repo.full_name }} |
56 | | - # Checkout for same-repo PRs, pushes, and pull_request_target |
57 | | - - uses: actions/checkout@v4 |
58 | | - if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository |
59 | | - with: |
60 | | - fetch-depth: 0 |
61 | | - ref: ${{ github.event.pull_request.head.ref || github.ref }} |
62 | | - repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} |
63 | | - token: ${{ secrets.PAT }} |
| 28 | + persist-credentials: false |
64 | 29 | - name: Install the latest version of uv |
65 | | - uses: astral-sh/setup-uv@v5 |
| 30 | + uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 |
66 | 31 | - name: Install tox |
67 | 32 | run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv |
68 | 33 | - name: Setup environment |
|
75 | 40 | run: .tox/cli-docs/bin/python scripts/build_cli_docs.py |
76 | 41 | - name: Build prompt data |
77 | 42 | run: .tox/cli-docs/bin/python scripts/build_prompt_data.py |
78 | | - - name: Commit and push if changed |
79 | | - if: github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event.pull_request.head.repo.full_name == github.repository |
80 | | - run: | |
81 | | - git config user.name "github-actions[bot]" |
82 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
83 | | - git add docs/cli-reference/ src/datamodel_code_generator/prompt_data.py |
84 | | - git diff --staged --quiet || git commit -m "docs: update CLI reference documentation and prompt data |
85 | | -
|
86 | | - 🤖 Generated by GitHub Actions" |
87 | | - git push |
0 commit comments