Skip to content
Open
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
19 changes: 18 additions & 1 deletion .github/scripts/restore-pending-videos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
# the PR every night. So: take every file the PR branch *added* under
# content/resources/videos/ (relative to its merge base with main) and put
# it in the working tree, unless main has a file at that path by now.
# Files the PR modified are not restored; the scripts regenerate them.
#
# Also take the PR's data/videos.toml, unless main changed it since the merge
# base (then main's edits win). Otherwise a weekly stats refresh would be
# undone the next night: the scripts keep the *stored* view counts, and the
# stored ones would be main's old counts again. The video pages follow from
# videos.toml, so the scripts regenerate them; other files the PR modified
# are not restored.
#
# Usage: restore-pending-videos.sh [BRANCH] [BASE]
# BRANCH defaults to automation/sync-videos, BASE to main.
Expand All @@ -18,6 +24,7 @@ set -euo pipefail
branch="${1:-automation/sync-videos}"
base="${2:-main}"
prefix="content/resources/videos/"
videos_toml="data/videos.toml"

if ! git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
echo "No pending branch $branch; nothing to restore."
Expand Down Expand Up @@ -52,3 +59,13 @@ if ((${#restored[@]})); then
fi

echo "Restored ${#restored[@]} file(s) from $branch (${#added[@]} added there, $skipped already on $base)."

merge_base=$(git merge-base "$remote_base" "$remote_branch")
if git diff --quiet "$merge_base" "$remote_branch" -- "$videos_toml"; then
echo "$videos_toml: unchanged on $branch; using $base's version."
elif ! git diff --quiet "$merge_base" "$remote_base" -- "$videos_toml"; then
echo "$videos_toml: changed on $base since $branch was created; using $base's version (the next stats refresh catches up)."
else
git restore --source="$remote_branch" --worktree -- "$videos_toml"
echo "$videos_toml: restored from $branch."
fi
6 changes: 5 additions & 1 deletion .github/workflows/sync-videos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,11 @@ jobs:
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ steps.app-token.outputs.token }}
sign-commits: true
# Not signed: signing sends every changed file in one API request,
# and with data/videos.toml (3.7 MB) that request times out now and
# then ("your input was too large"; 2 of the first 9 nights). A git
# push has no such limit, and the squash merge into main is signed.
sign-commits: false
branch: automation/sync-videos
delete-branch: true
# All of content/: renamed videos also update links in other pages.
Expand Down
Loading