Skip to content
Draft
Changes from 1 commit
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
Prev Previous commit
chore: breaking the infinite loop of build, by splitting build and de…
…ploy commands
  • Loading branch information
pranav-new-relic authored Nov 7, 2025
commit 7067c956a86df32ea837975539467e4cfcb01a8e
22 changes: 16 additions & 6 deletions .github/workflows/final-manual-deploy-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ jobs:
You can follow the build live [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
# This tag is CRUCIAL. It lets the final step find and replace this comment.
comment_tag: manual-build-comment
# THIS IS THE FIX for the pending comment
github_token: ${{ secrets.GITHUB_TOKEN }}

# We must check out the actual code from the PR head
- name: Checkout PR head
Expand All @@ -127,7 +129,6 @@ jobs:
# Set this to the Node.js version your docs site uses
node-version: '18'

# THIS IS THE MODIFIED STEP
- name: Install Dependencies
run: |
if [ -f yarn.lock ]; then
Expand All @@ -147,7 +148,7 @@ jobs:
- name: Install Netlify CLI
run: npm install -g netlify-cli

# This is the new build step. It REPLACES your 'curl' step.
# THIS STEP IS NOW SEPARATED INTO BUILD AND DEPLOY
- name: Build and Deploy Preview
id: netlify_deploy
# This is CRUCIAL! It lets the next step run even if this one fails.
Expand All @@ -156,9 +157,16 @@ jobs:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: |
# --alias creates a predictable URL like: deploy-preview-123.netlify.app
# --json captures the output so we can parse it
deploy_output=$(netlify deploy --build --json --alias="deploy-preview-${{ steps.pr_info.outputs.pr_number }}" --message="Deploy preview for PR #${{ steps.pr_info.outputs.pr_number }}")
# Step 1: Run the build. This WILL stream logs.
# If this fails, the 'continue-on-error' will catch it, and the
# 'Update PR comment' step will report the failure.
echo "Running Netlify Build... (logs will stream)"
netlify build

# Step 2: If build succeeded, deploy the site.
# This is fast and can safely use --json.
echo "Deploying to Netlify..."
deploy_output=$(netlify deploy --json --alias="deploy-preview-${{ steps.pr_info.outputs.pr_number }}" --message="Deploy preview for PR #${{ steps.pr_info.outputs.pr_number }}")

# Save the full output for debugging
echo "NETLIFY_DEPLOY_OUTPUT<<EOF" >> $GITHUB_ENV
Expand All @@ -173,7 +181,7 @@ jobs:

# Check if 'deploy_url' is null or empty, which indicates a build failure
if [ -z "$deploy_url" ] || [ "$deploy_url" == "null" ]; then
echo "Build failed! No deploy_url returned."
echo "Build failed or deploy_url not found!"
# This ensures the 'outcome' of this step is 'failure'
exit 1
fi
Expand All @@ -184,6 +192,8 @@ jobs:
with:
# This tag finds the "pending" comment and replaces it
comment_tag: manual-build-comment
# THIS IS THE FIX for the final comment
github_token: ${{ secrets.GITHUB_TOKEN }}
# This logic posts a different message based on the build step's outcome
message: |
${{ steps.netlify_deploy.outcome == 'success' && format('### <span aria-hidden="true">✅</span> Build Succeeded: Preview Ready!
Expand Down
Loading