|
11 | 11 | required: false |
12 | 12 | default: "" |
13 | 13 | pull_request: |
| 14 | + paths: |
| 15 | + - '.github/workflows/sync-cli-docs.yml' |
| 16 | + - 'hack/sync-cli-docs.sh' |
14 | 17 |
|
15 | 18 | permissions: |
16 | 19 | contents: write |
@@ -48,53 +51,33 @@ jobs: |
48 | 51 | path: cli-source |
49 | 52 | ref: ${{ steps.get-version.outputs.version }} |
50 | 53 | fetch-depth: 0 |
51 | | - - |
52 | | - name: Create update branch |
53 | | - id: create-branch |
54 | | - run: | |
55 | | - BRANCH_NAME="bot/sync-cli-docs-$(date +%Y%m%d-%H%M%S)" |
56 | | - git checkout -b "$BRANCH_NAME" |
57 | | - echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" |
58 | | - git config user.name "github-actions[bot]" |
59 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
60 | 54 | - |
61 | 55 | name: Run sync script |
62 | 56 | id: sync |
63 | | - run: | |
64 | | - set +e |
65 | | - ./hack/sync-cli-docs.sh HEAD cli-source |
66 | | - EXIT_CODE=$? |
67 | | - set -e |
68 | | - |
69 | | - if [ $EXIT_CODE -eq 0 ]; then |
70 | | - echo "changes=true" >> "$GITHUB_OUTPUT" |
71 | | - echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY" |
72 | | - elif [ $EXIT_CODE -eq 100 ]; then |
73 | | - echo "changes=false" >> "$GITHUB_OUTPUT" |
74 | | - echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY" |
75 | | - else |
76 | | - echo "::error::Script failed with exit code $EXIT_CODE" |
77 | | - exit $EXIT_CODE |
78 | | - fi |
79 | | -
|
80 | | - - |
81 | | - name: Show PR |
82 | | - if: steps.sync.outputs.changes == 'true' |
83 | | - run: | |
84 | | - git show "${{ steps.create-branch.outputs.branch_name }}" |
| 57 | + run: ./hack/sync-cli-docs.sh HEAD cli-source |
85 | 58 | - |
86 | 59 | name: Create Pull Request |
87 | | - if: steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request' |
88 | | - env: |
89 | | - GH_TOKEN: ${{ github.token }} |
90 | | - PR_BODY: | |
| 60 | + id: cpr |
| 61 | + uses: peter-evans/create-pull-request@v7 |
| 62 | + with: |
| 63 | + branch: bot/sync-cli-docs-${{ steps.get-version.outputs.version }} |
| 64 | + base: main |
| 65 | + delete-branch: true |
| 66 | + add-paths: | |
| 67 | + data/engine-cli/*.yaml |
| 68 | + commit-message: "cli: sync docs with docker/cli ${{ steps.sync.outputs.git_ref }}" |
| 69 | + title: "cli: sync docs with docker/cli" |
| 70 | + body: | |
91 | 71 | ## Summary |
92 | 72 |
|
93 | 73 | Automated sync of CLI documentation from docker/cli repository. |
| 74 | +
|
| 75 | + **CLI version**: ${{ steps.get-version.outputs.version }} |
| 76 | + **Git ref**: ${{ steps.sync.outputs.git_ref }} |
| 77 | + reviewers: "@engine" |
| 78 | + - |
| 79 | + name: Check outputs |
| 80 | + if: ${{ steps.cpr.outputs.pull-request-number }} |
94 | 81 | run: | |
95 | | - git push -u origin "${{ steps.create-branch.outputs.branch_name }}" |
96 | | - gh pr create \ |
97 | | - --title "cli: sync docs with docker/cli" \ |
98 | | - --body "$PR_BODY" \ |
99 | | - --base main \ |
100 | | - --head "${{ steps.create-branch.outputs.branch_name }}" |
| 82 | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |
| 83 | + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
0 commit comments