Project 2 โ€บ 08 Deploy automatically on merge to mainGitHub โ†—
๐Ÿค– AI Prompt โ€” stuck? paste this

โ€œShow me how to trigger a Render deploy from GitHub Actions using a deploy hook URL stored as a secret, only after my publish job succeeds, using needs: to chain jobs.โ€

08 โ€” Deploy automatically when you merge to main

Category: Continuous Deployment ยท Priority: High ยท Step: 9

Close the loop: a successful merge to main triggers a deploy. This is full CD.

๐ŸŽฏ What is this task?

You've built, tested, and published. The final piece is deployment: when code lands on main and the image is published, automatically tell your host (e.g. Render from Project 1) to pull the new image and go live โ€” with zero manual steps.

๐Ÿ”— Builds on: Project 1 Render deploy + lesson 06 (publish to GHCR).

๐Ÿค– AI Prompt

"Show me how to trigger a Render deploy from GitHub Actions using a deploy hook URL stored as a secret, only after my publish job succeeds. Use needs: to chain jobs."

๐Ÿ“‹ Step-by-step

Chain a deploy job after publish using needs::

  deploy:
    runs-on: ubuntu-latest
    needs: publish              # only run if publish succeeded
    if: github.ref == 'refs/heads/main'
    steps:
      - name: Trigger Render deploy
        run: curl -fsSL "${{ secrets.RENDER_DEPLOY_HOOK }}"
  • needs: publish โ†’ deploy waits for publish and runs only if it passed.
  • RENDER_DEPLOY_HOOK is a secret URL from Render โ†’ Settings โ†’ Deploy Hook.
  • Hitting that URL tells Render to pull the latest image and redeploy.

The full pipeline now: push โ†’ test โ†’ build โ†’ publish โ†’ deploy, all automatic. That's CI/CD.

โœ… Done when

  • A deploy job runs only after publish succeeds (needs:)
  • Merging to main updates the live site with no manual steps
  • You can describe the full push-to-production pipeline end to end

๐Ÿ“ Quiz

Answer all 2 questions correctly to complete this lesson.

1. What does `needs: publish` do for the deploy job?
2. Triggering a Render deploy hook is done by...
โ† PreviousPass the quiz to completeNext โ†’