From 53f20d017bf2d81e0b51170c9bb2f7db2d0589e5 Mon Sep 17 00:00:00 2001 From: bhattu-gauravv Date: Mon, 2 Mar 2026 11:21:41 +0530 Subject: [PATCH 1/3] feat: add staging --- .github/workflows/sync-docs.yaml | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/sync-docs.yaml diff --git a/.github/workflows/sync-docs.yaml b/.github/workflows/sync-docs.yaml new file mode 100644 index 0000000..e3c6cbd --- /dev/null +++ b/.github/workflows/sync-docs.yaml @@ -0,0 +1,62 @@ +name: Sync Docs to Central Repo + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'squadcastv1/docs/**' + - 'squadcastv1/*.md' + +jobs: + sync-docs: + runs-on: ubuntu-latest + + env: + SDK_LANG: python + DOCS_PATH: squadcastv1/docs + CENTRAL_REPO: bhattu-gauravv/squadcast-sdk-docs + + steps: + - name: Checkout SDK repo + uses: actions/checkout@v4 + + - name: Checkout central docs repo + uses: actions/checkout@v4 + with: + repository: ${{ env.CENTRAL_REPO }} + token: ${{ secrets.DOCS_REPO_PAT }} + path: central-docs + + - name: Create branch and sync docs + run: | + BRANCH="docs-sync/${SDK_LANG}-${{ github.sha }}" + cd central-docs + git config user.name "speakeasy-docs-bot" + git config user.email "docs-bot@solarwinds.com" + git checkout -b "$BRANCH" + rm -rf "${SDK_LANG}/" + mkdir -p "${SDK_LANG}" + cp -r "../${DOCS_PATH}/." "${SDK_LANG}/" + SDK_ROOT=$(dirname "../${DOCS_PATH}") + find "${SDK_ROOT}" -maxdepth 1 -name "*.md" -exec cp {} "${SDK_LANG}/" \; + git add . + if git diff --staged --quiet; then + echo "No doc changes to sync. Exiting." + exit 0 + fi + git commit -m "docs(${SDK_LANG}): sync from squadcast-sdk-${SDK_LANG} @ ${{ github.sha }}" + git push origin "$BRANCH" + + - name: Create Pull Request + run: | + BRANCH="docs-sync/${SDK_LANG}-${{ github.sha }}" + gh pr create \ + --repo "${CENTRAL_REPO}" \ + --head "$BRANCH" \ + --base main \ + --title "docs(${SDK_LANG}): sync from squadcast-sdk-${SDK_LANG}" \ + --body "Automated docs sync triggered by commit [${{ github.sha }}](https://github.com/solarwinds/squadcast-sdk-${SDK_LANG}/commit/${{ github.sha }}) in \`squadcast-sdk-${SDK_LANG}\`." + env: + GH_TOKEN: ${{ secrets.DOCS_REPO_PAT }} From d033acb3268ff7c8f6ecc3d822c7ac4dfb464a87 Mon Sep 17 00:00:00 2001 From: bhattu-gauravv Date: Mon, 2 Mar 2026 11:25:12 +0530 Subject: [PATCH 2/3] feat: add staging branch --- .github/workflows/sync-docs.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-docs.yaml b/.github/workflows/sync-docs.yaml index e3c6cbd..5abc9b0 100644 --- a/.github/workflows/sync-docs.yaml +++ b/.github/workflows/sync-docs.yaml @@ -5,6 +5,7 @@ on: push: branches: - main + - staging paths: - 'squadcastv1/docs/**' - 'squadcastv1/*.md' @@ -28,13 +29,31 @@ jobs: repository: ${{ env.CENTRAL_REPO }} token: ${{ secrets.DOCS_REPO_PAT }} path: central-docs + fetch-depth: 0 - name: Create branch and sync docs run: | - BRANCH="docs-sync/${SDK_LANG}-${{ github.sha }}" + # Target staging in central repo when triggered from staging, else main + if [[ "${{ github.ref_name }}" == "staging" ]]; then + BASE_BRANCH="staging" + else + BASE_BRANCH="main" + fi + + BRANCH="docs-sync/${SDK_LANG}-${BASE_BRANCH}-${{ github.sha }}" cd central-docs git config user.name "speakeasy-docs-bot" git config user.email "docs-bot@solarwinds.com" + + # Ensure base branch exists in central repo; create from main if not + git fetch origin + if git ls-remote --exit-code --heads origin "$BASE_BRANCH" > /dev/null 2>&1; then + git checkout "$BASE_BRANCH" + else + git checkout -b "$BASE_BRANCH" + git push origin "$BASE_BRANCH" + fi + git checkout -b "$BRANCH" rm -rf "${SDK_LANG}/" mkdir -p "${SDK_LANG}" @@ -55,7 +74,7 @@ jobs: gh pr create \ --repo "${CENTRAL_REPO}" \ --head "$BRANCH" \ - --base main \ + --base "$BASE_BRANCH" \ --title "docs(${SDK_LANG}): sync from squadcast-sdk-${SDK_LANG}" \ --body "Automated docs sync triggered by commit [${{ github.sha }}](https://github.com/solarwinds/squadcast-sdk-${SDK_LANG}/commit/${{ github.sha }}) in \`squadcast-sdk-${SDK_LANG}\`." env: From 46e54c3557b30caf570fbdef9738c5565a23825b Mon Sep 17 00:00:00 2001 From: bhattu-gauravv Date: Mon, 2 Mar 2026 12:20:36 +0530 Subject: [PATCH 3/3] feat: copy docs --- .github/workflows/sync-docs.yaml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sync-docs.yaml b/.github/workflows/sync-docs.yaml index 5abc9b0..e8bbbb5 100644 --- a/.github/workflows/sync-docs.yaml +++ b/.github/workflows/sync-docs.yaml @@ -32,6 +32,7 @@ jobs: fetch-depth: 0 - name: Create branch and sync docs + id: sync run: | # Target staging in central repo when triggered from staging, else main if [[ "${{ github.ref_name }}" == "staging" ]]; then @@ -48,7 +49,7 @@ jobs: # Ensure base branch exists in central repo; create from main if not git fetch origin if git ls-remote --exit-code --heads origin "$BASE_BRANCH" > /dev/null 2>&1; then - git checkout "$BASE_BRANCH" + git checkout -b "$BASE_BRANCH" "origin/$BASE_BRANCH" else git checkout -b "$BASE_BRANCH" git push origin "$BASE_BRANCH" @@ -57,25 +58,38 @@ jobs: git checkout -b "$BRANCH" rm -rf "${SDK_LANG}/" mkdir -p "${SDK_LANG}" - cp -r "../${DOCS_PATH}/." "${SDK_LANG}/" + cp -r "../${DOCS_PATH}" "${SDK_LANG}/docs" SDK_ROOT=$(dirname "../${DOCS_PATH}") find "${SDK_ROOT}" -maxdepth 1 -name "*.md" -exec cp {} "${SDK_LANG}/" \; git add . if git diff --staged --quiet; then - echo "No doc changes to sync. Exiting." + echo "No doc changes to sync. Skipping." + echo "has_changes=false" >> "$GITHUB_OUTPUT" exit 0 fi git commit -m "docs(${SDK_LANG}): sync from squadcast-sdk-${SDK_LANG} @ ${{ github.sha }}" - git push origin "$BRANCH" + git push --force origin "$BRANCH" + echo "has_changes=true" >> "$GITHUB_OUTPUT" - name: Create Pull Request + if: steps.sync.outputs.has_changes == 'true' run: | - BRANCH="docs-sync/${SDK_LANG}-${{ github.sha }}" - gh pr create \ + if [[ "${{ github.ref_name }}" == "staging" ]]; then + BASE_BRANCH="staging" + else + BASE_BRANCH="main" + fi + BRANCH="docs-sync/${SDK_LANG}-${BASE_BRANCH}-${{ github.sha }}" + EXISTING_PR=$(gh pr list --repo "${CENTRAL_REPO}" --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || echo "") + if [[ -n "$EXISTING_PR" ]]; then + echo "PR #${EXISTING_PR} already exists for branch $BRANCH, skipping creation." + else + gh pr create \ --repo "${CENTRAL_REPO}" \ --head "$BRANCH" \ --base "$BASE_BRANCH" \ --title "docs(${SDK_LANG}): sync from squadcast-sdk-${SDK_LANG}" \ --body "Automated docs sync triggered by commit [${{ github.sha }}](https://github.com/solarwinds/squadcast-sdk-${SDK_LANG}/commit/${{ github.sha }}) in \`squadcast-sdk-${SDK_LANG}\`." + fi env: GH_TOKEN: ${{ secrets.DOCS_REPO_PAT }}