File tree Expand file tree Collapse file tree 2 files changed +105
-0
lines changed
Expand file tree Collapse file tree 2 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 1+ name : sync-cli-docs
2+
3+ on :
4+ schedule :
5+ # Run daily at 02:00 UTC
6+ - cron : ' 0 2 * * *'
7+ workflow_dispatch :
8+
9+ permissions :
10+ contents : write
11+ pull-requests : write
12+
13+ jobs :
14+ sync-cli-docs :
15+ runs-on : ubuntu-24.04
16+ steps :
17+ -
18+ name : Checkout docs repo
19+ uses : actions/checkout@v5
20+ with :
21+ fetch-depth : 0
22+ -
23+ name : Checkout docker/cli repo
24+ uses : actions/checkout@v5
25+ with :
26+ repository : docker/cli
27+ path : cli-source
28+ fetch-depth : 0
29+ -
30+ name : Add upstream remote for docker/cli
31+ run : |
32+ cd cli-source
33+ git remote add upstream https://github.com/docker/cli.git
34+ git fetch upstream
35+ -
36+ name : Create update branch
37+ id : create-branch
38+ run : |
39+ BRANCH_NAME="bot/sync-cli-docs-$(date +%Y%m%d-%H%M%S)"
40+ git checkout -b "$BRANCH_NAME"
41+ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
42+ -
43+ name : Run sync script
44+ id : sync
45+ run : |
46+ if ./hack/sync-cli-docs.sh cli-source origin/master; then
47+ echo "changes=true" >> $GITHUB_OUTPUT
48+ echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY"
49+ else
50+ echo "changes=false" >> $GITHUB_OUTPUT
51+ echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY"
52+ fi
53+ -
54+ name : Create Pull Request
55+ if : steps.sync.outputs.changes == 'true'
56+ env :
57+ GH_TOKEN : ${{ github.token }}
58+ PR_BODY : |
59+ ## Summary
60+
61+ Automated sync of CLI documentation from docker/cli repository.
62+ run : |
63+ git push origin "${{ steps.create-branch.outputs.branch_name }}"
64+ gh pr create \
65+ --title "cli: sync docs with docker/cli" \
66+ --body "$PR_BODY" \
67+ --base main \
68+ --head "${{ steps.create-branch.outputs.branch_name }}"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+
5+ main () {
6+ local cli_source=" ${1:- $HOME / src/ cli} "
7+ local branch_name=" ${2:- upstream/ master} "
8+ local worktree_dir=" ./internal-update-cli-docs"
9+
10+ (
11+ GIT_DIR=" $cli_source /.git"
12+ GIT_DIR=" $GIT_DIR " git fetch upstream
13+ GIT_DIR=" $GIT_DIR " git worktree add " $worktree_dir " " $branch_name "
14+ ) || return $?
15+ trap " GIT_DIR=\" $cli_source /.git\" git worktree remove \" $worktree_dir \" --force" EXIT
16+
17+ (cd " $worktree_dir " ; make -f docker.Makefile yamldocs) || return $?
18+ cp " $worktree_dir " /docs/yaml/* .yaml ./data/engine-cli/
19+
20+ if git diff --quiet " ./data/engine-cli/*.yaml" ; then
21+ printf " \e[32m✅ Already up to date\e[0m\n"
22+ return 1
23+ fi
24+
25+ echo -e " ℹ️ Changes detected:"
26+ git diff --stat " ./data/engine-cli/*.yaml" || true
27+
28+ NICE_GIT_REF=$( cd " $worktree_dir " && git describe --always --dirty) || return $?
29+
30+ git add " ./data/engine-cli/*.yaml"
31+ git commit -s -S -m " cli: sync docs with docker/cli $NICE_GIT_REF "
32+
33+ printf " \e[32m✅ Committed changes\e[0m\n"
34+ return 0
35+ }
36+
37+ main " $@ "
You can’t perform that action at this time.
0 commit comments