1
0
mirror of https://github.com/docker/docs.git synced 2026-10-23 18:09:02 +03:00
Files
docs/.github/workflows/sync-docker-agent-docs.yml
Sayt0 d55fcce4fe docker-agent: single-source docs via Hugo module mount (#25480)
Single-sources the Docker Agent documentation from the product repo via
a Hugo module mount, joining the pattern used by CLI, Buildx, Compose,
BuildKit, Model Runner, and the Moby API. Closes the docs.docker.com
side of docker/docker-agent#3371.

## Context

The pages under `content/manuals/ai/docker-agent/` were hand-authored
duplicates of the product repo docs and drifted on every upstream
change. The source docs were converted to portable Hugo-clean Markdown
and prepared for mounting in docker/docker-agent#3413 and
docker/docker-agent#3414, released in docker-agent v1.96.0.

## What changed

| Change | Detail |
|---|---|
| `go.mod` | `github.com/docker/docker-agent v1.96.0` added to `require`
and `tool` |
| `hugo.yaml` | `module.imports` mounts the eight docs sections and
`demo.gif` onto `content/manuals/ai/docker-agent/` |
| Content | The 16 hand-authored pages are removed; `_index.md` stays
hand-authored (landing page), with links rewritten to the mounted pages
|
| `_vendor/` | 99 vendored files from the module |
| `.github/workflows/sync-docker-agent-docs.yml` | Daily poll that
vendors the latest docker-agent release and opens a bot PR, modeled on
`sync-cli-docs.yml` |

## URL preservation

Every removed page keeps its URL: the mounted pages carry `aliases`
front matter (added upstream in docker/docker-agent#3414), and
`_index.md` keeps aliases for the removed section indexes
(`integrations/`, `reference/`, `reference/examples/`).

| Old URL | Redirects to |
|---|---|
| `/ai/docker-agent/tutorial/` | `.../getting-started/quickstart/` |
| `/ai/docker-agent/best-practices/` | `.../guides/tips/` |
| `/ai/docker-agent/evals/` | `.../features/evaluation/` |
| `/ai/docker-agent/local-models/` | `.../providers/local/` |
| `/ai/docker-agent/model-providers/` | `.../providers/overview/` |
| `/ai/docker-agent/rag/` | `.../tools/rag/` |
| `/ai/docker-agent/sharing-agents/` | `.../concepts/distribution/` |
| `/ai/docker-agent/integrations/{a2a,acp,mcp}/` | `.../features/a2a/`,
`.../features/acp/`, `.../tools/mcp/` |
| `/ai/docker-agent/reference/{cli,config,toolsets}/` |
`.../features/cli/`, `.../configuration/overview/`,
`.../configuration/tools/` |
| `/ai/docker-agent/integrations/`, `/ai/docker-agent/reference/`,
`/ai/docker-agent/reference/examples/` | `/ai/docker-agent/` |

## Mount scope

All eight sections are mounted rather than a core subset:
`refLinksErrorLevel: ERROR` makes partial mounts fail the build for any
relative link into an unmounted page, and the link closure from the core
sections already pulls in 68 of the 90 pages. Mounting everything keeps
the build link-safe and removes all drift.

## Keeping the pin fresh

On each docker-agent release, `sync-docker-agent-docs.yml` (daily poll,
mirrors `sync-cli-docs.yml`) compares the latest release tag against the
pinned version and opens a bot PR with the re-vendored module.
docker/docker-agent also runs `validate-upstream.yml` on every docs PR,
so upstream changes that would break this site fail CI before they merge
(two source-side issues were caught exactly this way while preparing
this change).

## Validation

`docker buildx bake validate` passes on this branch:

| Target | Result |
|---|---|
| test (Hugo build + htmltest) | pass (3196 pages, 1515 aliases, 3110
documents tested) |
| lint | pass |
| unused-media | pass |
| test-go-redirects | pass |
| validate-vendor | pass |
| dockerfile-lint | pass |

`actionlint` passes on the new workflow.
2026-07-03 14:31:26 +02:00

131 lines
5.0 KiB
YAML

name: sync-docker-agent-docs
on:
schedule:
# Run daily at 02:30 UTC, offset from sync-cli-docs
- cron: '30 2 * * *'
workflow_dispatch:
inputs:
version:
description: "(optional) docker-agent version - defaults to the latest release tag"
required: false
default: ""
pull_request:
paths:
- '.github/workflows/sync-docker-agent-docs.yml'
permissions:
contents: write
pull-requests: write
env:
BRANCH_NAME: "bot/sync-docker-agent-docs"
MODULE_NAME: "github.com/docker/docker-agent"
jobs:
sync-docker-agent-docs:
runs-on: ubuntu-24.04
steps:
-
name: Checkout docs repo
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
fetch-depth: 0
-
name: Get target version
id: get-version
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
VERSION=$(gh release view --repo docker/docker-agent --json tagName --jq .tagName)
fi
CURRENT=$(go list -m -f '{{ .Version }}' "$MODULE_NAME" || true)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "docker-agent version: **$VERSION** (currently pinned: **$CURRENT**)" | tee -a "$GITHUB_STEP_SUMMARY"
-
name: Set up Docker Buildx
if: steps.get-version.outputs.version != steps.get-version.outputs.current
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
-
# go mod edit sets the version before plain make vendor: passing
# VENDOR_MODULE would run hugo mod get, which records docker-agent's
# full transitive graph as indirect requires in go.mod.
name: Update vendor
if: steps.get-version.outputs.version != steps.get-version.outputs.current
run: |
go mod edit -require "${MODULE_NAME}@${{ steps.get-version.outputs.version }}"
make vendor
-
name: Detect changes
id: changes
if: steps.get-version.outputs.version != steps.get-version.outputs.current
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> "$GITHUB_OUTPUT"
echo "Changes detected - syncing Docker Agent docs" >> "$GITHUB_STEP_SUMMARY"
else
echo "changes=false" >> "$GITHUB_OUTPUT"
echo "No changes to sync - Docker Agent docs are up to date" >> "$GITHUB_STEP_SUMMARY"
fi
-
name: Commit changes
if: steps.changes.outputs.changes == 'true'
env:
BRANCH_NAME: ${{ env.BRANCH_NAME }}
VERSION: ${{ steps.get-version.outputs.version }}
run: |
git checkout -b "$BRANCH_NAME"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "docker-agent: sync docs with docker-agent $VERSION"
-
name: Create or update Pull Request
if: steps.changes.outputs.changes == 'true' && github.event_name != 'pull_request'
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
PR_TITLE: "docker-agent: sync docs with docker-agent ${{ steps.get-version.outputs.version }}"
PR_BODY: |
## Summary
Automated sync of Docker Agent documentation from the docker/docker-agent repository.
**docker-agent version:** ${{ steps.get-version.outputs.version }}
---
> [!IMPORTANT]
> **Reviewer:** Please close and reopen this PR to trigger CI checks.
> See: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow
run: |
# Check for existing open PR from this branch
EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json url --jq ".[0].url // empty")
if [ -n "$EXISTING_PR" ]; then
echo "Updating existing PR: $EXISTING_PR" >> "$GITHUB_STEP_SUMMARY"
git push -u origin "$BRANCH_NAME" --force
gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
else
# Check if a closed PR with the same title already exists
CLOSED_PR=$(gh pr list --state closed --search "$PR_TITLE in:title" --json url --jq ".[0].url // empty")
if [ -n "$CLOSED_PR" ]; then
echo "A closed PR already exists for this version: $CLOSED_PR" >> "$GITHUB_STEP_SUMMARY"
echo "Skipping PR creation."
exit 0
fi
echo "Creating new PR" >> "$GITHUB_STEP_SUMMARY"
git push -u origin "$BRANCH_NAME"
gh pr create \
--title "$PR_TITLE" \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME"
fi