Deploy Hooks
Trigger a deploy with a single HTTP request.
Deploy hooks enable you to trigger an on-demand deploy of your Render service with a single HTTP request.
Each service has a secret deploy hook URL, available from its Settings tab in the Render Dashboard:
Your deploy hook URL is a secret! Provide it only to people and systems you trust to initiate deploys.
If you believe a deploy hook URL has been compromised, replace it by clicking Regenerate Hook.
To trigger a deploy, send a basic GET
or POST
request to your service’s deploy hook URL—no special headers are required.
curl https://api.render.com/deploy/srv-xyz…
Use cases
Use deploy hooks to trigger deploys from:
- CI/CD environments like GitHub Actions (see an example)
- Render cron jobs (to redeploy your service on a regular schedule)
- Headless CMS systems like Contentful
Using with GitHub Actions
You might want to trigger a service deploy from your CI/CD environment whenever certain conditions are met (such as when all of your tests pass). Let’s set this up using deploy hooks and GitHub Actions.
1. Create a repository secret
Deploy hook URLs are secret values, so we need to make sure to store ours as a secret in our GitHub repo:
- Go to your GitHub repo’s Settings page.
- Click Secrets and variables > Actions.
- Click New repository secret. Create a secret with the name
RENDER_DEPLOY_HOOK_URL
and provide your deploy hook URL as the value.
2. Add a GitHub workflow
Now that we’ve added our deploy hook URL, let’s create a GitHub workflow that uses it:
- Create a
.github/workflows
directory in your repo if it doesn’t already exist. GitHub Actions automatically detects and runs any workflows defined in this folder. - Add a YAML file to this directory to represent your new workflow. The example below uses the file path
.github/workflows/ci.yml
. - Define logic in your workflow to trigger a deploy after any prerequisite steps succeed. See the example.
- Commit all of your changes.
Example workflow
This example workflow defines a job named ci
that includes two steps (Test
and Deploy
). The workflow runs whenever any pull request is opened against main
, or when commits are pushed to main
.
- The
Test
step runs the repo’s defined unit tests. - The
Deploy
step executes acurl
request to our deploy hook URL only if the current branch ismain
and theTest
step succeeded.
# .github/workflows/ci.yml
on:
pull_request:
push:
branches: [main]
jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Test
run: |
npm install
npm run test
- name: Deploy
# Only run this step if the branch is main
if: github.ref == 'refs/heads/main'
env:
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
run: |
curl "$deploy_url"