Skip to content
Draft
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
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1678,11 +1678,8 @@ jobs:
elif [ "${{ github.event_name }}" = "pull_request" ]; then
echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT

# DISABLED: deploy-to-staging label detection is disabled.
# The label workflow has fundamental problems — admin deploys are global
# (not per-site) and main merges overwrite the deployment immediately.
# See deploy-to-staging.yml for details.
echo "deploy=" >> $GITHUB_OUTPUT
DEPLOY=$(echo '${{ toJson(github.event.pull_request.labels.*.name) }}' | jq -r 'if any(. == "deploy-to-staging") then "true" else "" end')
echo "deploy=$DEPLOY" >> $GITHUB_OUTPUT
else
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
Expand Down
59 changes: 47 additions & 12 deletions .github/workflows/deploy-to-staging.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
name: Deploy to Staging

# DISABLED: The deploy-to-staging label workflow is currently broken and disabled.
# Problems:
# 1. Admin is global — deploying a PR's admin overwrites admin-forward/ for ALL staging
# sites, not just demo.ghost.is. Per-site admin versioning is needed first.
# 2. Main merges overwrite — any merge to main triggers a full staging rollout that
# overwrites both the server version on demo.ghost.is and admin-forward/ globally.
# The deployment lasts only until the next merge to main, making it unreliable.
# See: https://www.notion.so/ghost/Proposal-Per-site-admin-versioning-31951439c03081daa133eb0215642202

on:
pull_request_target:
types: [labeled]
types: [labeled, unlabeled, closed]

jobs:
deploy:
name: Deploy to Staging
# Runs when the "deploy-to-staging" label is added — requires collaborator write access.
# Fork PRs are rejected because they don't have GHCR images (CI uses artifact transfer).
if: >-
false
&& github.event.label.name == 'deploy-to-staging'
github.event.label.name == 'deploy-to-staging'
&& github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -125,3 +115,48 @@ jobs:
"pr_number": "${{ env.PR_NUMBER }}",
"deploy": "true"
}

# Clear version pins when label is removed or PR is closed
cleanup:
name: Cleanup staging pins
if: >-
(github.event.action == 'unlabeled' && github.event.label.name == 'deploy-to-staging')
|| (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'deploy-to-staging'))
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- name: Deactivate GitHub deployment
uses: actions/github-script@v8
with:
script: |
const environment = `staging-pr-${{ github.event.pull_request.number }}`;
const { data: deployments } = await github.rest.repos.listDeployments({
owner: context.repo.owner,
repo: context.repo.repo,
environment
});
for (const d of deployments) {
await github.rest.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: d.id,
state: 'inactive'
});
}
if (deployments.length) {
console.log(`Deactivated ${deployments.length} deployment(s) for ${environment}`);
}

- name: Dispatch unpin to Ghost-Moya
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.CANARY_DOCKER_BUILD }}
repository: TryGhost/Ghost-Moya
event-type: unpin-staging-sites
client-payload: >-
{
"site_ids": "303000",
"pr_number": "${{ github.event.pull_request.number }}"
Comment on lines +158 to +161
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for references to site_ids or 303000 in the repository to understand context
rg -n '303000' --type yaml --type json
rg -nP 'site_ids?\s*[=:]' --type yaml -C2

Repository: TryGhost/Ghost

Length of output: 40


🏁 Script executed:

# Search for references to unpin-staging-sites event and Ghost-Moya
rg -n 'unpin-staging-sites' 
rg -n 'Ghost-Moya\|ghost-moya'
rg -n 'site_ids\|site.id' 

# Check if there's documentation about the site IDs
rg -in 'staging.*site.*id\|site.*303000'

# Get the full deploy-to-staging.yml file to understand context
fd 'deploy-to-staging.yml' --exec cat -n {}

Repository: TryGhost/Ghost

Length of output: 40


🏁 Script executed:

# First, verify the file exists and get its location
fd 'deploy-to-staging.yml'

# Try to read the specific file mentioned in the review
cat -n .github/workflows/deploy-to-staging.yml | sed -n '125,165p'

# Also search for any comments or documentation in the workflow file
cat -n .github/workflows/deploy-to-staging.yml | grep -A5 -B5 'site_ids\|unpin-staging\|303000'

Repository: TryGhost/Ghost

Length of output: 2160


🏁 Script executed:

# Search for any documentation or comments about the staging site or site_ids
rg -n 'site.id\|site_id\|staging.*site\|303' .github/workflows/

# Look for any README or documentation files that might explain the site configuration
fd -e md -e txt -e json | xargs rg -l 'staging\|site.*id' 2>/dev/null | head -20

# Check if there are any comments in the workflow file around this section
cat -n .github/workflows/deploy-to-staging.yml | sed -n '100,125p'

# Check the end of the file for any documentation
tail -50 .github/workflows/deploy-to-staging.yml | cat -n

Repository: TryGhost/Ghost

Length of output: 3460


Add a comment explaining the hardcoded staging site ID.

The site_ids: "303000" is a magic constant with no explanation. Add an inline comment (e.g., # Staging site ID) to clarify what this ID represents for future maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/deploy-to-staging.yml around lines 158 - 161, The workflow
YAML contains a hardcoded staging site ID "303000" without explanation. Add an
inline comment next to the "site_ids": "303000" line to clarify that this value
is the staging site ID. This will help future maintainers understand the purpose
of this constant in the deploy-to-staging job.

}
Loading