ci: Add automated CLI documentation sync workflow #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: sync-cli-docs | |
| on: | |
| schedule: | |
| # Run daily at 02:00 UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| pull_request: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-cli-docs: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - | |
| name: Checkout docs repo | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - | |
| name: Get version from hugo.yaml | |
| id: get-version | |
| run: | | |
| VERSION=$(grep "docker_ce_version:" hugo.yaml | awk '{print $2}' | tr -d '"') | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - | |
| name: Checkout docker/cli repo | |
| uses: actions/checkout@v5 | |
| with: | |
| repository: docker/cli | |
| path: cli-source | |
| ref: v"${{ steps.get-version.outputs.version }}" | |
| fetch-depth: 0 | |
| - | |
| name: Add upstream remote for docker/cli | |
| run: | | |
| cd cli-source | |
| git remote add upstream https://github.com/docker/cli.git | |
| git fetch upstream | |
| - | |
| 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" | |
| - | |
| name: Run sync script | |
| id: sync | |
| run: | | |
| if ./hack/sync-cli-docs.sh HEAD cli-source; then | |
| echo "changes=true" >> "$GITHUB_OUTPUT" | |
| echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY" | |
| else | |
| echo "changes=false" >> "$GITHUB_OUTPUT" | |
| echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY" | |
| fi | |
| - | |
| name: Show PR | |
| if: steps.sync.outputs.changes == 'true' | |
| run: | | |
| git show "${{ steps.create-branch.outputs.branch_name }}" | |
| - | |
| name: Create Pull Request | |
| if: steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_BODY: | | |
| ## Summary | |
| Automated sync of CLI documentation from docker/cli repository. | |
| run: | | |
| git push 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 }}" |