diff --git a/package.json b/package.json index 13b67feee4..dc9564db55 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "purge-old-workflow-runs": "tsx src/workflows/purge-old-workflow-runs.js", "ready-for-docs-review": "tsx src/workflows/ready-for-docs-review.ts", "release-banner": "tsx src/ghes-releases/scripts/release-banner.ts", + "repo-sync": "./src/workflows/local-repo-sync.sh", "reusables": "tsx src/content-render/scripts/reusables-cli.ts", "rendered-content-link-checker": "tsx src/links/scripts/rendered-content-link-checker.ts", "rendered-content-link-checker-cli": "tsx src/links/scripts/rendered-content-link-checker-cli.ts", diff --git a/src/workflows/local-repo-sync.sh b/src/workflows/local-repo-sync.sh new file mode 100755 index 0000000000..0d375f9781 --- /dev/null +++ b/src/workflows/local-repo-sync.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +echo "> This script assumes docs and docs-internal are cloned together in the same directory already." + +echo "> Making sure the repos are a sibiling directories..." +cd ../docs || (echo "Repo docs not found as a sibling directory" && exit 1) +cd ../docs-internal || (echo "Repo docs-internal not found as a sibling directory" && exit 1) +echo "> Found directories for repos docs and docs-internal" + +echo "> Checking out main branch and updating both repositories..." +cd ../docs +git checkout main +git pull +cd ../docs-internal +git checkout main +git pull +echo "> Both repositories are in main and up-to-date" + +echo "> Set up remotes if they aren't there..." +cd ../docs +git remote show docs-internal || git remote add docs-internal ../docs-internal +cd ../docs-internal +git remote show docs || git remote add docs ../docs +echo "> Remotes set on docs and docs-internal" + +echo "> Fetch and merge both repositories..." +cd ../docs +git fetch docs-internal main +git merge docs-internal/main +cd ../docs-internal +git fetch docs main +git merge docs/main +echo "> Both repositories have each other's latest changes in main" + +echo "> Push up both repositories..." +cd ../docs +git push --no-verify +cd ../docs-internal +git push --no-verify +echo "> Both repositories are pushed to origin"