Skip to content

Commit ef55023

Browse files
committed
ci: use create-pull-request action for cli sync
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent 91fa587 commit ef55023

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

.github/workflows/sync-cli-docs.yml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
required: false
1212
default: ""
1313
pull_request:
14+
paths:
15+
- '.github/workflows/sync-cli-docs.yml'
16+
- 'hack/sync-cli-docs.sh'
1417

1518
permissions:
1619
contents: write
@@ -49,12 +52,8 @@ jobs:
4952
ref: ${{ steps.get-version.outputs.version }}
5053
fetch-depth: 0
5154
-
52-
name: Create update branch
53-
id: create-branch
55+
name: Git config
5456
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"
5857
git config user.name "github-actions[bot]"
5958
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
6059
-
@@ -65,36 +64,37 @@ jobs:
6564
./hack/sync-cli-docs.sh HEAD cli-source
6665
EXIT_CODE=$?
6766
set -e
68-
67+
6968
if [ $EXIT_CODE -eq 0 ]; then
70-
echo "changes=true" >> "$GITHUB_OUTPUT"
7169
echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY"
7270
elif [ $EXIT_CODE -eq 100 ]; then
73-
echo "changes=false" >> "$GITHUB_OUTPUT"
7471
echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY"
7572
else
7673
echo "::error::Script failed with exit code $EXIT_CODE"
7774
exit $EXIT_CODE
7875
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 }}"
8576
-
8677
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: |
78+
id: cpr
79+
uses: peter-evans/create-pull-request@v7
80+
with:
81+
token: ${{ secrets.GITHUB_TOKEN }}
82+
branch: bot/sync-cli-docs-${{ steps.get-version.outputs.version }}
83+
base: main
84+
delete-branch: true
85+
add-paths: |
86+
data/engine-cli/*.yaml
87+
title: "cli: sync docs with docker/cli"
88+
body: |
9189
## Summary
9290
9391
Automated sync of CLI documentation from docker/cli repository.
92+
93+
**CLI version**: ${{ steps.get-version.outputs.version }}
94+
reviewers: "@engine"
95+
-
96+
name: Check outputs
97+
if: ${{ steps.cpr.outputs.pull-request-number }}
9498
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 }}"
99+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
100+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"

0 commit comments

Comments
 (0)