Skip to content

Commit 7e4b3da

Browse files
authored
Merge pull request #786 from docker/docs
ci(release): skip docs PR when CLI reference is unchanged
2 parents 91e9b08 + 7fa7f6f commit 7e4b3da

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,26 +526,55 @@ jobs:
526526
permissions:
527527
contents: read
528528
steps:
529+
- name: Check if CLI docs changed
530+
id: check-docs
531+
env:
532+
GH_TOKEN: ${{ secrets.CLI_RELEASE_PAT }}
533+
RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
534+
PREVIOUS_TAG: ${{ needs.prepare.outputs.previous_tag }}
535+
run: |
536+
if [ -z "$PREVIOUS_TAG" ]; then
537+
echo "No previous tag — assuming docs changed"
538+
echo "changed=true" >> "$GITHUB_OUTPUT"
539+
exit 0
540+
fi
541+
CHANGED=$(gh api repos/docker/model-runner/compare/${PREVIOUS_TAG}...${RELEASE_TAG} \
542+
--jq '[.files[].filename | select(startswith("cmd/cli/docs/reference/"))] | length')
543+
if [ "$CHANGED" -gt 0 ]; then
544+
echo "CLI docs changed ($CHANGED files)"
545+
echo "changed=true" >> "$GITHUB_OUTPUT"
546+
else
547+
echo "No CLI docs changes between $PREVIOUS_TAG and $RELEASE_TAG — skipping"
548+
echo "changed=false" >> "$GITHUB_OUTPUT"
549+
fi
550+
529551
- name: Checkout docs
552+
if: steps.check-docs.outputs.changed == 'true'
530553
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
531554
with:
532555
repository: docker/docs
533556
token: ${{ secrets.CLI_RELEASE_PAT }}
534557
fetch-depth: 0
535558

536559
- name: Set up Go
560+
if: steps.check-docs.outputs.changed == 'true'
537561
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417
538562
with:
539563
go-version: 1.25.8
540564
cache: true
541565

542566
- name: Vendor model-runner CLI docs
567+
if: steps.check-docs.outputs.changed == 'true'
543568
env:
544569
RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
545570
run: |
546571
VENDOR_MODULE=github.com/docker/model-runner@${RELEASE_TAG} make vendor
572+
# Remove the second require block added by `go get` — the docs repo
573+
# only needs the direct dependency in the first require block.
574+
awk '/^require \(/{n++} n==2{if(/^\)/) n=3; next} n!=2' go.mod > go.mod.tmp && mv go.mod.tmp go.mod
547575
548576
- name: Create pull request
577+
if: steps.check-docs.outputs.changed == 'true'
549578
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
550579
with:
551580
token: ${{ secrets.DOCKER_DOCS }}

0 commit comments

Comments
 (0)