-
Notifications
You must be signed in to change notification settings - Fork 246
DOCS-1629 - Add /stage-deploy and /review-deploy commands for two staging environments #6704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2f58974
Add /stage-deploy skill for shared staging environment
mafsumo eb9fb73
Add Slack notifications and conflict detection to stage-deploy skill
mafsumo 8a17ceb
Address Kim's review feedback on stage-deploy
mafsumo 9d189ed
Merge remote-tracking branch 'origin/main' into feat/stage-deploy-wor…
mafsumo 944e15d
DOCS-1629 - Add /review-deploy and /review-teardown commands for seco…
mafsumo e21a65d
Merge branch 'main' into feat/stage-deploy-workflow-clean
kimsauce b6122b7
DOCS-1629 - Drop Slack notifications, fix stage-deploy purpose framing
mafsumo 965a651
Merge remote-tracking branch 'origin/feat/stage-deploy-workflow-clean…
mafsumo 4a316ee
DOCS-1629 - Fix deploy push, displaced-PR comment, multi-branch confl…
mafsumo 733696c
Merge remote-tracking branch 'origin/main' into feat/stage-deploy-wor…
mafsumo 6398a72
DOCS-1629 - Fix fork PRs, self-conflict, and deleted-doc previews
mafsumo 15568a5
Merge remote-tracking branch 'origin/main' into feat/stage-deploy-wor…
mafsumo 543039d
Merge branch 'main' into feat/stage-deploy-workflow-clean
mafsumo 62bb913
Merge branch 'main' into feat/stage-deploy-workflow-clean
mafsumo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,222 @@ | ||
| # Stage Deploy Skill | ||
|
|
||
| Deploy PR branches to the shared Pantheon staging environment for external review. | ||
|
|
||
| ## Purpose | ||
|
|
||
| Enable external reviewers (legal, compliance, product) to preview documentation changes in a live staging environment before merge. Uses the existing `helpdocs` staging environment and `staging/**` branch workflow. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Deploy a PR to Staging | ||
|
|
||
| ``` | ||
| /stage-deploy {pr-number-or-branch} | ||
| ``` | ||
|
|
||
| **Examples:** | ||
| - `/stage-deploy 6701` | ||
| - `/stage-deploy docs-update-jira-skill-fields` | ||
|
|
||
| ### Remove a Staging Branch | ||
|
|
||
| ``` | ||
| /stage-teardown {pr-number-or-branch} | ||
| ``` | ||
|
|
||
| **Examples:** | ||
| - `/stage-teardown 6701` | ||
| - `/stage-teardown docs-update-jira-skill-fields` | ||
|
|
||
| ## How It Works | ||
|
|
||
| ### Deploy Flow | ||
|
|
||
| 1. **Resolve input to PR branch**: | ||
| - If input is numeric: look up PR and get head branch | ||
| - If input is branch name: use directly | ||
| - Validate PR exists and is open | ||
|
|
||
| 2. **Check for conflicts**: | ||
| ```bash | ||
| # List existing staging/pr-* branches | ||
| git ls-remote --heads origin 'refs/heads/staging/pr-*' | ||
| ``` | ||
| - If staging branches exist, identify: | ||
| - Which PR number(s) from branch names | ||
| - Who created each branch (via gh pr view) | ||
| - Preview URL from the PRs | ||
| - Ask user if they want to: | ||
| - Continue and overwrite existing staging | ||
| - Cancel and coordinate with team | ||
|
|
||
| 3. **Detect article URL from PR files**: | ||
| ```bash | ||
| # Get files changed in PR | ||
| gh pr view {pr-number} --json files --jq '.files[].path' | ||
|
|
||
| # Filter for docs markdown files | ||
| # Convert docs/path/to/article.md → /docs/path/to/article/ | ||
| # Example: docs/integrations/jira.md → /docs/integrations/jira/ | ||
| ``` | ||
|
|
||
| 4. **Send Slack notification (deploy starting)**: | ||
| ```bash | ||
| # Post to #web-ops via webhook | ||
| curl -X POST $WEBOPS_SLACK_URL \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "text": "🚀 Staging deployment started for PR #{number}", | ||
| "blocks": [{ | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Staging deployment started*\n• PR: <{pr-url}|#{number} - {title}>\n• Author: {author}\n• Staging: <https://helpdocs-sumo-logic.pantheonsite.io/help/|helpdocs>\n• Preview: <https://helpdocs-sumo-logic.pantheonsite.io/help{article-path}|{article-name}>\n• Monitor: <{actions-url}|GitHub Actions>" | ||
| } | ||
| }] | ||
| }' | ||
| ``` | ||
|
|
||
| **Article URL detection**: | ||
| - If PR modifies a single doc file: include direct preview link | ||
| - If PR modifies multiple docs: list primary file or skip article link | ||
| - If PR modifies non-doc files only: omit article preview | ||
|
|
||
| 5. **Create/update staging branch**: | ||
| ```bash | ||
| git fetch origin {pr-branch} | ||
| git branch -f staging/pr-{number} origin/{pr-branch} | ||
|
mafsumo marked this conversation as resolved.
Outdated
|
||
| git push origin staging/pr-{number} | ||
| ``` | ||
|
|
||
| 6. **Existing workflow automatically triggers**: | ||
| - Push to `staging/**` triggers `workflow_deploy-to-pantheon-staging.yml` | ||
| - Workflow builds site from staging branch | ||
| - Deploys to `helpdocs` multidev environment | ||
| - Workflow sends its own Slack notification on success/failure | ||
|
|
||
| 7. **Post PR comment** with staging URL and instructions | ||
|
|
||
| ### Teardown Flow | ||
|
|
||
| 1. **Resolve to staging branch name**: `staging/pr-{number}` or `staging/{branch-name}` | ||
|
|
||
| 2. **Verify branch exists**: | ||
| ```bash | ||
| git ls-remote --heads origin refs/heads/staging/pr-{number} | ||
| ``` | ||
| - If not found, inform user and exit gracefully | ||
|
|
||
| 3. **Send Slack notification (teardown)**: | ||
| ```bash | ||
| curl -X POST $WEBOPS_SLACK_URL \ | ||
| -H 'Content-Type: application/json' \ | ||
| -d '{ | ||
| "text": "🗑️ Staging environment torn down", | ||
| "blocks": [{ | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": "*Staging environment removed*\n• Branch: staging/pr-{number}\n• Previous deployment remains live until next deploy" | ||
| } | ||
| }] | ||
| }' | ||
| ``` | ||
|
|
||
| 4. **Delete staging branch**: | ||
| ```bash | ||
| git push origin --delete staging/pr-{number} | ||
| ``` | ||
|
|
||
| 5. **Post PR comment** confirming deletion | ||
|
|
||
| ## Staging Environment | ||
|
|
||
| - **Single shared environment**: `https://helpdocs-sumo-logic.pantheonsite.io/help/` | ||
| - **HTTP basic auth protected**: Contact docs team for credentials | ||
| - **Only one PR at a time**: Deploying a new PR overwrites the previous deployment | ||
| - **Automatic coordination**: Skill checks for conflicts and posts to #web-ops Slack channel | ||
|
|
||
| ## Conflict Detection | ||
|
|
||
| Before deploying, the skill checks for existing `staging/pr-*` branches: | ||
|
|
||
| ```bash | ||
| # Example output if conflict detected: | ||
| ⚠️ Staging environment conflict detected! | ||
|
|
||
| Currently staged PR(s): | ||
| • PR #6701 - "Update Jira skill fields" | ||
| - Author: @mafsumo | ||
| - Branch: staging/pr-6701 | ||
| - Preview: https://helpdocs-sumo-logic.pantheonsite.io/help/ | ||
|
|
||
| Do you want to: | ||
| 1. Continue and overwrite (will notify team in Slack) | ||
| 2. Cancel and coordinate with @mafsumo first | ||
| ``` | ||
|
|
||
| This prevents accidentally overwriting a colleague's staging deployment. | ||
|
|
||
| ## Limitations | ||
|
|
||
| - **Single staging slot**: Only one PR can be deployed to staging at a time | ||
| - **No automatic cleanup**: Staging branches persist until explicitly deleted | ||
| - **Manual coordination**: Team must communicate to avoid overwriting each other's deployments | ||
| - **Build time**: 5-10 minutes for this large Docusaurus site | ||
| - **Shared URL**: All reviewers see the same staging environment (whatever was deployed last) | ||
|
|
||
| ## Slack Notifications | ||
|
|
||
| The skill posts to **#web-ops** Slack channel (same as existing workflows): | ||
|
|
||
| **On deploy start:** | ||
| ``` | ||
| 🚀 Staging deployment started for PR #6701 | ||
| • PR: #6701 - Update Jira skill fields | ||
| • Author: @mafsumo | ||
| • Staging: https://helpdocs-sumo-logic.pantheonsite.io/help/ | ||
| • Preview: https://helpdocs-sumo-logic.pantheonsite.io/help/docs/integrations/jira/ | ||
| • Monitor: [GitHub Actions] | ||
| ``` | ||
|
|
||
| If the PR modifies multiple docs, the preview link shows the primary changed file (first .md file in docs/). | ||
|
|
||
| **On teardown:** | ||
| ``` | ||
| 🗑️ Staging environment torn down | ||
| • Branch: staging/pr-6701 | ||
| • Previous deployment remains live until next deploy | ||
| ``` | ||
|
|
||
| **On deploy complete:** (via existing workflow) | ||
| ``` | ||
| 🟢 helpdocs staging site deployed | ||
| [Link to staging site] | ||
| ``` | ||
|
|
||
| This ensures the team is always aware of staging environment changes. | ||
|
|
||
| ## Slack Webhook | ||
|
|
||
| The skill uses the same `WEBOPS_SLACK_URL` secret as existing workflows. To access: | ||
|
|
||
| ```bash | ||
| # Check if webhook is available (secret not exposed directly) | ||
| gh secret list --repo SumoLogic/sumologic-documentation | grep WEBOPS_SLACK_URL | ||
| ``` | ||
|
|
||
| If the secret is not accessible locally, the skill will: | ||
| 1. Skip Slack notifications | ||
| 2. Warn the user | ||
| 3. Proceed with deployment (posting to #web-ops is optional, not blocking) | ||
|
|
||
| ## Implementation Notes | ||
|
|
||
| This skill uses: | ||
| - **Git commands** for branch management | ||
| - **GitHub CLI (`gh`)** for PR metadata | ||
| - **curl** for Slack webhooks (optional) | ||
| - **Existing workflow** `workflow_deploy-to-pantheon-staging.yml` handles deployment | ||
|
|
||
| No new GitHub Actions workflows required. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.