Skip to content

Commit 910eeb0

Browse files
dvdksnclaude
andcommitted
ci: simplify workflow — static matrix, no prepare job
Replace JavaScript-based dynamic matrix with a static YAML matrix. Version resolution is a simple `gh api` call in the sync job itself. Dispatch filtering uses a job-level `if` condition. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8cc3b5f commit 910eeb0

1 file changed

Lines changed: 34 additions & 81 deletions

File tree

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

Lines changed: 34 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# For each configured upstream repo, runs its docs bake target via git context
55
# to generate YAML, copies it to data/cli/<folder>/, and opens a PR.
66
#
7-
# Upstream contract: a bake target that outputs *.yaml CLI reference files.
8-
# Target names and output paths are configured per-repo in the `repos` array below.
9-
# Long-term goal: standardize on a common `docs-release` target name across repos.
7+
# To add a new repo: add an entry to the matrix and to the workflow_dispatch options.
108

119
name: sync-upstream-cli
1210

@@ -17,15 +15,15 @@ on:
1715
workflow_dispatch:
1816
inputs:
1917
repo:
20-
description: "Upstream repo (e.g., docker/buildx)"
18+
description: "Upstream repo"
2119
required: true
2220
type: choice
2321
options:
2422
- docker/buildx
2523
- docker/compose
2624
- docker/model-runner
2725
version:
28-
description: "Git tag to sync (e.g., v0.33.0). Leave empty to use latest release."
26+
description: "Git tag (e.g., v0.33.0). Leave empty for latest release."
2927
required: false
3028
type: string
3129

@@ -38,82 +36,31 @@ env:
3836
SETUP_BUILDKIT_IMAGE: "moby/buildkit:latest"
3937

4038
jobs:
41-
prepare:
42-
runs-on: ubuntu-24.04
43-
outputs:
44-
matrix: ${{ steps.matrix.outputs.result }}
45-
steps:
46-
- name: Build matrix
47-
id: matrix
48-
uses: actions/github-script@v7
49-
with:
50-
script: |
51-
// Each upstream repo with its bake configuration.
52-
// - target: the bake target name that generates CLI YAML
53-
// - files: bake file path (empty = root docker-bake.hcl)
54-
// - yaml_glob: where the YAML ends up in the bake output
55-
const repos = [
56-
{
57-
repo: "docker/buildx",
58-
folder: "buildx",
59-
target: "update-docs",
60-
files: "",
61-
yaml_glob: "out/reference",
62-
},
63-
{
64-
repo: "docker/compose",
65-
folder: "compose",
66-
target: "docs-update",
67-
files: "",
68-
yaml_glob: "out/reference",
69-
},
70-
{
71-
repo: "docker/model-runner",
72-
folder: "model",
73-
target: "update-docs",
74-
files: "cmd/cli/docker-bake.hcl",
75-
yaml_glob: ".",
76-
},
77-
];
78-
79-
const inputRepo = context.payload.inputs?.repo || "";
80-
const inputVersion = context.payload.inputs?.version || "";
81-
82-
let matrix = [];
83-
for (const r of repos) {
84-
if (inputRepo && r.repo !== inputRepo) continue;
85-
86-
let version = inputVersion;
87-
if (!version) {
88-
try {
89-
const { data: release } = await github.rest.repos.getLatestRelease({
90-
owner: r.repo.split("/")[0],
91-
repo: r.repo.split("/")[1],
92-
});
93-
version = release.tag_name;
94-
} catch (e) {
95-
core.warning(`Could not fetch latest release for ${r.repo}: ${e.message}`);
96-
continue;
97-
}
98-
}
99-
100-
matrix.push({ ...r, version });
101-
}
102-
103-
core.info(JSON.stringify(matrix, null, 2));
104-
return matrix;
105-
10639
sync:
107-
needs: prepare
108-
if: ${{ fromJSON(needs.prepare.outputs.matrix).length > 0 }}
10940
runs-on: ubuntu-24.04
41+
if: ${{ !inputs.repo || inputs.repo == matrix.repo }}
11042
strategy:
11143
fail-fast: false
11244
matrix:
113-
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
45+
include:
46+
- { repo: docker/buildx, folder: buildx, target: update-docs, files: "", yaml_glob: "out/reference" }
47+
- { repo: docker/compose, folder: compose, target: docs-update, files: "", yaml_glob: "out/reference" }
48+
- { repo: docker/model-runner, folder: model, target: update-docs, files: "cmd/cli/docker-bake.hcl", yaml_glob: "." }
11449
env:
11550
BRANCH: "bot/sync-${{ matrix.folder }}-cli"
11651
steps:
52+
- name: Resolve version
53+
id: version
54+
env:
55+
GH_TOKEN: ${{ github.token }}
56+
run: |
57+
if [ -n "${{ inputs.version }}" ]; then
58+
echo "tag=${{ inputs.version }}" >> "$GITHUB_OUTPUT"
59+
else
60+
TAG=$(gh api "repos/${{ matrix.repo }}/releases/latest" --jq '.tag_name')
61+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
62+
fi
63+
11764
- name: Checkout docker/docs
11865
uses: actions/checkout@v5
11966
with:
@@ -123,14 +70,15 @@ jobs:
12370
id: check
12471
env:
12572
GH_TOKEN: ${{ github.token }}
73+
VERSION: ${{ steps.version.outputs.tag }}
12674
run: |
12775
EXISTING=$(gh pr list --state all \
128-
--search "cli(${{ matrix.folder }}): sync docs ${{ matrix.version }} in:title" \
76+
--search "cli(${{ matrix.folder }}): sync docs $VERSION in:title" \
12977
--json state --jq '.[0].state // empty')
13078
13179
if [ "$EXISTING" = "MERGED" ] || [ "$EXISTING" = "CLOSED" ]; then
13280
echo "skip=true" >> "$GITHUB_OUTPUT"
133-
echo "Already synced ${{ matrix.repo }} ${{ matrix.version }}" >> "$GITHUB_STEP_SUMMARY"
81+
echo "Already synced ${{ matrix.repo }} $VERSION" >> "$GITHUB_STEP_SUMMARY"
13482
else
13583
echo "skip=false" >> "$GITHUB_OUTPUT"
13684
fi
@@ -146,7 +94,7 @@ jobs:
14694
if: steps.check.outputs.skip != 'true'
14795
uses: docker/bake-action@v7
14896
with:
149-
source: "${{ github.server_url }}/${{ matrix.repo }}.git#${{ matrix.version }}"
97+
source: "${{ github.server_url }}/${{ matrix.repo }}.git#${{ steps.version.outputs.tag }}"
15098
files: ${{ matrix.files || '' }}
15199
targets: ${{ matrix.target }}
152100
provenance: false
@@ -165,11 +113,13 @@ jobs:
165113
- name: Check for changes
166114
if: steps.check.outputs.skip != 'true'
167115
id: diff
116+
env:
117+
VERSION: ${{ steps.version.outputs.tag }}
168118
run: |
169119
git add "data/cli/${{ matrix.folder }}/"
170120
if git diff --cached --quiet; then
171121
echo "changes=false" >> "$GITHUB_OUTPUT"
172-
echo "No changes detected for ${{ matrix.repo }} ${{ matrix.version }}" >> "$GITHUB_STEP_SUMMARY"
122+
echo "No changes for ${{ matrix.repo }} $VERSION" >> "$GITHUB_STEP_SUMMARY"
173123
else
174124
echo "changes=true" >> "$GITHUB_OUTPUT"
175125
echo '```' >> "$GITHUB_STEP_SUMMARY"
@@ -179,19 +129,22 @@ jobs:
179129
180130
- name: Commit and push
181131
if: steps.check.outputs.skip != 'true' && steps.diff.outputs.changes == 'true'
132+
env:
133+
VERSION: ${{ steps.version.outputs.tag }}
182134
run: |
183135
git config user.name "github-actions[bot]"
184136
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
185137
git checkout -b "$BRANCH"
186-
git commit -m "cli(${{ matrix.folder }}): sync docs ${{ matrix.version }}"
138+
git commit -m "cli(${{ matrix.folder }}): sync docs $VERSION"
187139
git push -u origin "$BRANCH" --force
188140
189141
- name: Create or update PR
190142
if: steps.check.outputs.skip != 'true' && steps.diff.outputs.changes == 'true'
191143
env:
192144
GH_TOKEN: ${{ github.token }}
145+
VERSION: ${{ steps.version.outputs.tag }}
193146
run: |
194-
TITLE="cli(${{ matrix.folder }}): sync docs ${{ matrix.version }}"
147+
TITLE="cli(${{ matrix.folder }}): sync docs $VERSION"
195148
196149
EXISTING=$(gh pr list --state open \
197150
--head "$BRANCH" --json url --jq '.[0].url // empty')
@@ -204,8 +157,8 @@ jobs:
204157
| | |
205158
|---|---|
206159
| **Tool** | \`${{ matrix.folder }}\` |
207-
| **Version** | \`${{ matrix.version }}\` |
208-
| **Source** | [${{ matrix.repo }}@${{ matrix.version }}](${{ github.server_url }}/${{ matrix.repo }}/tree/${{ matrix.version }}) |
160+
| **Version** | \`$VERSION\` |
161+
| **Source** | [${{ matrix.repo }}@$VERSION](${{ github.server_url }}/${{ matrix.repo }}/tree/$VERSION) |
209162
EOF
210163
)
211164

0 commit comments

Comments
 (0)