Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/actions/sync-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,16 @@ runs:
git checkout -B "$branch"
git add -A "vendor/$product"
git commit -m "docs($product): sync from ${GITHUB_REPOSITORY}@${short}"
git push --force-with-lease origin "$branch"
# The branch is rebuilt from the product repo every run, so its previous
# contents are never a base to preserve. A lease would compare against a
# remote-tracking ref this shallow checkout never fetched, which rejects
# every run after the branch first exists.
git push --force origin "$branch"

if ! gh pr view "$branch" --json number >/dev/null 2>&1; then
# Match only an open PR. `gh pr view <branch>` also resolves closed and
# merged ones, so once the first sync PR merges the create is skipped
# forever and each run pushes a branch nobody reviews.
if [ -z "$(gh pr list --head "$branch" --state open --json number --jq '.[0].number // empty')" ]; then
# Build the body with printf rather than a literal newline in the YAML.
# A continuation line starting at column 1 would close this block
# scalar, and indenting it instead would put four or more leading
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,20 @@ jobs:
BASE: ${{ github.event.pull_request.base.sha }}
HEAD: ${{ github.event.pull_request.head.sha }}
AUTHOR: ${{ github.event.pull_request.user.login }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
set -euo pipefail
case "$AUTHOR" in
*"[bot]"|rivet-docs-sync*) echo "sync bot; skipping"; exit 0 ;;
esac

# The sync force-pushes docs-sync/* from scratch every run, so nothing
# written there by hand survives regardless. Exempt the branch as well
# as the bot, or a sync PR reopened by a human fails this guard.
case "$HEAD_REF" in
docs-sync/*) echo "sync branch; skipping"; exit 0 ;;
esac

changed=$(git diff --name-only "$BASE" "$HEAD" -- vendor/ || true)
if [ -n "$changed" ]; then
echo "::error::vendor/ is generated by the sync-docs action. Edit the docs in the product repo instead."
Expand Down
Loading