Skip to content

Commit b2c44d4

Browse files
committed
refactor: move cli sync commit logic from script to gha
Signed-off-by: David Karlsson <[email protected]>
1 parent ef55023 commit b2c44d4

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

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

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,10 @@ jobs:
5151
path: cli-source
5252
ref: ${{ steps.get-version.outputs.version }}
5353
fetch-depth: 0
54-
-
55-
name: Git config
56-
run: |
57-
git config user.name "github-actions[bot]"
58-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
5954
-
6055
name: Run sync script
6156
id: sync
62-
run: |
63-
set +e
64-
./hack/sync-cli-docs.sh HEAD cli-source
65-
EXIT_CODE=$?
66-
set -e
67-
68-
if [ $EXIT_CODE -eq 0 ]; then
69-
echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY"
70-
elif [ $EXIT_CODE -eq 100 ]; then
71-
echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY"
72-
else
73-
echo "::error::Script failed with exit code $EXIT_CODE"
74-
exit $EXIT_CODE
75-
fi
57+
run: ./hack/sync-cli-docs.sh HEAD cli-source
7658
-
7759
name: Create Pull Request
7860
id: cpr
@@ -84,13 +66,15 @@ jobs:
8466
delete-branch: true
8567
add-paths: |
8668
data/engine-cli/*.yaml
69+
commit-message: "cli: sync docs with docker/cli ${{ steps.sync.outputs.git_ref }}"
8770
title: "cli: sync docs with docker/cli"
8871
body: |
8972
## Summary
9073
9174
Automated sync of CLI documentation from docker/cli repository.
9275
9376
**CLI version**: ${{ steps.get-version.outputs.version }}
77+
**Git ref**: ${{ steps.sync.outputs.git_ref }}
9478
reviewers: "@engine"
9579
-
9680
name: Check outputs

hack/sync-cli-docs.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,10 @@ main() {
1717
(set -e; cd "$worktree_dir"; make -f docker.Makefile yamldocs || { printf "::error::Failed to generate YAML docs!\n"; exit 1; }) || return $?
1818
cp "$worktree_dir"/docs/yaml/*.yaml ./data/engine-cli/
1919

20-
if git diff --quiet "./data/engine-cli/*.yaml"; then
21-
printf "\e[32m✅ Already up to date\e[0m\n"
22-
return 100
23-
fi
24-
25-
echo -e "ℹ️ Changes detected:"
26-
git diff --stat "./data/engine-cli/*.yaml" || true
27-
2820
NICE_GIT_REF=$(cd "$worktree_dir" && git describe --always --dirty) || return $?
21+
echo "git_ref=$NICE_GIT_REF" >> "${GITHUB_OUTPUT:-/dev/stdout}"
2922

30-
git add "./data/engine-cli/*.yaml"
31-
32-
git commit -m "cli: sync docs with docker/cli $NICE_GIT_REF"
33-
34-
printf "\e[32m✅ Committed changes\e[0m\n"
23+
printf "\e[32m✅ Synced CLI docs from %s\e[0m\n" "$NICE_GIT_REF"
3524
return 0
3625
}
3726

0 commit comments

Comments
 (0)