From fb361a203300cab62f11c0ed4c10d6dd87aae12a Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 5 Jan 2026 08:03:09 +0100 Subject: [PATCH] ci: use create-pull-request action for cli sync Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- .github/workflows/sync-cli-docs.yml | 65 +++++++++++------------------ hack/sync-cli-docs.sh | 15 +------ 2 files changed, 26 insertions(+), 54 deletions(-) diff --git a/.github/workflows/sync-cli-docs.yml b/.github/workflows/sync-cli-docs.yml index 3838cfb75d8..e3219bc318a 100644 --- a/.github/workflows/sync-cli-docs.yml +++ b/.github/workflows/sync-cli-docs.yml @@ -11,6 +11,9 @@ on: required: false default: "" pull_request: + paths: + - '.github/workflows/sync-cli-docs.yml' + - 'hack/sync-cli-docs.sh' permissions: contents: write @@ -48,53 +51,33 @@ jobs: path: cli-source ref: ${{ steps.get-version.outputs.version }} fetch-depth: 0 - - - name: Create update branch - id: create-branch - run: | - BRANCH_NAME="bot/sync-cli-docs-$(date +%Y%m%d-%H%M%S)" - git checkout -b "$BRANCH_NAME" - echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - name: Run sync script id: sync - run: | - set +e - ./hack/sync-cli-docs.sh HEAD cli-source - EXIT_CODE=$? - set -e - - if [ $EXIT_CODE -eq 0 ]; then - echo "changes=true" >> "$GITHUB_OUTPUT" - echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY" - elif [ $EXIT_CODE -eq 100 ]; then - echo "changes=false" >> "$GITHUB_OUTPUT" - echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY" - else - echo "::error::Script failed with exit code $EXIT_CODE" - exit $EXIT_CODE - fi - - - - name: Show PR - if: steps.sync.outputs.changes == 'true' - run: | - git show "${{ steps.create-branch.outputs.branch_name }}" + run: ./hack/sync-cli-docs.sh HEAD cli-source - name: Create Pull Request - if: steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request' - env: - GH_TOKEN: ${{ github.token }} - PR_BODY: | + id: cpr + uses: peter-evans/create-pull-request@v7 + with: + branch: bot/sync-cli-docs-${{ steps.get-version.outputs.version }} + base: main + delete-branch: true + add-paths: | + data/engine-cli/*.yaml + commit-message: "cli: sync docs with docker/cli ${{ steps.sync.outputs.git_ref }}" + title: "cli: sync docs with docker/cli" + body: | ## Summary Automated sync of CLI documentation from docker/cli repository. + + **CLI version**: ${{ steps.get-version.outputs.version }} + **Git ref**: ${{ steps.sync.outputs.git_ref }} + reviewers: "@engine" + - + name: Check outputs + if: ${{ steps.cpr.outputs.pull-request-number }} run: | - git push -u origin "${{ steps.create-branch.outputs.branch_name }}" - gh pr create \ - --title "cli: sync docs with docker/cli" \ - --body "$PR_BODY" \ - --base main \ - --head "${{ steps.create-branch.outputs.branch_name }}" + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" diff --git a/hack/sync-cli-docs.sh b/hack/sync-cli-docs.sh index 0747dd5109f..e6220f5ff25 100755 --- a/hack/sync-cli-docs.sh +++ b/hack/sync-cli-docs.sh @@ -17,21 +17,10 @@ main() { (set -e; cd "$worktree_dir"; make -f docker.Makefile yamldocs || { printf "::error::Failed to generate YAML docs!\n"; exit 1; }) || return $? cp "$worktree_dir"/docs/yaml/*.yaml ./data/engine-cli/ - if git diff --quiet "./data/engine-cli/*.yaml"; then - printf "\e[32m✅ Already up to date\e[0m\n" - return 100 - fi - - echo -e "ℹ️ Changes detected:" - git diff --stat "./data/engine-cli/*.yaml" || true - NICE_GIT_REF=$(cd "$worktree_dir" && git describe --always --dirty) || return $? + echo "git_ref=$NICE_GIT_REF" >> "${GITHUB_OUTPUT:-/dev/stdout}" - git add "./data/engine-cli/*.yaml" - - git commit -m "cli: sync docs with docker/cli $NICE_GIT_REF" - - printf "\e[32m✅ Committed changes\e[0m\n" + printf "\e[32m✅ Synced CLI docs from %s\e[0m\n" "$NICE_GIT_REF" return 0 }