GitHub Action to deploy PR to Render

Hello, in a current project, we have staging and production environments on Render. I want to be able to deploy to staging when a PR to main is created. The action is expected to deploy the changes in the PR. I have attempted to create a GitHub Action for that, however, it keeps deploying main instead.

This is what the GitHub action looks like, is there something I might be missing?

name: Deploy to Render

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  deploy-to-staging:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        env:
          REF: ${{ github.event.pull_request.head.sha }}

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.0.0'

      - name: Install dependencies
        run: bundle install

      - name: Deploy to Staging
        env:
          RENDER_STAGING_WEBHOOK: ${{ secrets.RENDER_STAGING_WEBHOOK }}
        run: curl -X POST "${{ env.RENDER_STAGING_WEBHOOK }}&ref=${{ env.REF }}"

Thanks

What branch is the RENDER_STATING_WEBHOOK target set to deploy in the dashboard?

John B
Render Support, UTC+1 :uk:

main.

I guess that means it will only deploy the main branch. Right?

Exactly, see https://docs.render.com/blueprint-spec#branch for details,

John B
Render Support, UTC+1 :uk: