|
| 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 | + inputs: |
| 9 | + version: |
| 10 | + description: "(optional) Docker CLI version - defaults to docker_ce_version in hugo.yaml" |
| 11 | + required: false |
| 12 | + default: "" |
| 13 | + pull_request: |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + pull-requests: write |
| 18 | + |
| 19 | +jobs: |
| 20 | + sync-cli-docs: |
| 21 | + runs-on: ubuntu-24.04 |
| 22 | + steps: |
| 23 | + - |
| 24 | + name: Checkout docs repo |
| 25 | + uses: actions/checkout@v5 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + - |
| 29 | + name: Get version from hugo.yaml |
| 30 | + id: get-version |
| 31 | + run: | |
| 32 | + if [ -n "${{ inputs.version }}" ]; then |
| 33 | + VERSION="${{ inputs.version }}" |
| 34 | + else |
| 35 | + VERSION=$(grep "docker_ce_version:" hugo.yaml | awk '{print $2}' | tr -d '"') |
| 36 | + fi |
| 37 | + VERSION=29.2.0-rc.1 |
| 38 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 39 | + echo "Docker CLI version: **$VERSION**" | tee -a "$GITHUB_STEP_SUMMARY" |
| 40 | + - |
| 41 | + name: Checkout docker/cli repo |
| 42 | + uses: actions/checkout@v5 |
| 43 | + with: |
| 44 | + repository: docker/cli |
| 45 | + path: cli-source |
| 46 | + ref: v${{ steps.get-version.outputs.version }} |
| 47 | + fetch-depth: 0 |
| 48 | + - |
| 49 | + name: Add upstream remote for docker/cli |
| 50 | + run: | |
| 51 | + cd cli-source |
| 52 | + git remote add upstream https://github.com/docker/cli.git |
| 53 | + git fetch upstream |
| 54 | + - |
| 55 | + name: Create update branch |
| 56 | + id: create-branch |
| 57 | + run: | |
| 58 | + BRANCH_NAME="bot/sync-cli-docs-$(date +%Y%m%d-%H%M%S)" |
| 59 | + git checkout -b "$BRANCH_NAME" |
| 60 | + echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT" |
| 61 | + - |
| 62 | + name: Run sync script |
| 63 | + id: sync |
| 64 | + run: | |
| 65 | + if ./hack/sync-cli-docs.sh HEAD cli-source; then |
| 66 | + echo "changes=true" >> "$GITHUB_OUTPUT" |
| 67 | + echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY" |
| 68 | + else |
| 69 | + echo "changes=false" >> "$GITHUB_OUTPUT" |
| 70 | + echo "No changes to sync - CLI docs are up to date" >> "$GITHUB_STEP_SUMMARY" |
| 71 | + fi |
| 72 | +
|
| 73 | + - |
| 74 | + name: Show PR |
| 75 | + if: steps.sync.outputs.changes == 'true' |
| 76 | + run: | |
| 77 | + git show "${{ steps.create-branch.outputs.branch_name }}" |
| 78 | + - |
| 79 | + name: Create Pull Request |
| 80 | + if: steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request' |
| 81 | + env: |
| 82 | + GH_TOKEN: ${{ github.token }} |
| 83 | + PR_BODY: | |
| 84 | + ## Summary |
| 85 | +
|
| 86 | + Automated sync of CLI documentation from docker/cli repository. |
| 87 | + run: | |
| 88 | + git push origin "${{ steps.create-branch.outputs.branch_name }}" |
| 89 | + gh pr create \ |
| 90 | + --title "cli: sync docs with docker/cli" \ |
| 91 | + --body "$PR_BODY" \ |
| 92 | + --base main \ |
| 93 | + --head "${{ steps.create-branch.outputs.branch_name }}" |
0 commit comments