Yes, you can use the Render CLI instead of curl! The Render CLI provides a cleaner interface for managing deployments. However, the Render CLI doesn't have a direct command to update the image path of a service, so you'll still need to trigger a deployment.
Here's the updated workflow using the Render CLI:
yaml
name: Build, Push & Deploy to Render
on:
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# --- Build and Push Docker Image to GHCR ---
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
# --- Install Render CLI ---
- name: Install Render CLI
run: |
curl -sSL https://render.com/install.sh | sh
echo "$HOME/.render/bin" >> $GITHUB_PATH
# --- Deploy to Render ---
- name: Deploy to Render using CLI
env:
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
RENDER_SERVICE_ID: ${{ secrets.RENDER_SERVICE_ID }}
IMAGE_PATH: ghcr.io/${{ github.repository }}:${{ github.sha }}
run: |
echo "Updating Render service to use image: $IMAGE_PATH"
# The Render CLI doesn't have a direct command to update image path,
# so we still need to use the API for this specific operation
curl --request PATCH \
--url https://api.render.com/v1/services/$RENDER_SERVICE_ID \
--header "Authorization: Bearer $RENDER_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"serviceDetails": {
"image": {
"path": "'"$IMAGE_PATH"'"
}
}
}'
# Give Render a moment to create the new deployment
sleep 10
# Use Render CLI to monitor the deployment
echo "Monitoring deployment status..."
# The render CLI will automatically poll and wait for the deployment to complete
# It will exit with status 0 if successful, non-zero if failed
render deploys list --service-id $RENDER_SERVICE_ID --limit 1 --json | jq -r '.[0].id' | xargs -I {} render deploys wait {}
Unfortunately, as of my knowledge cutoff, the Render CLI doesn't provide a command to directly update a service's image path. The CLI is primarily designed for:
Listing services and deployments
Monitoring deployment status
Managing environment variables
Viewing logs
So for the specific operation of updating the image path, you still need to use the API directly with curl. However, the CLI does provide the render deploys wait command which is cleaner than manually polling with curl.
If you prefer to stick with pure curl for consistency, the previous version of the workflow is perfectly fine. The Render CLI is most useful when you're doing operations it directly supports, but for this particular use case, the API approach is actually more straightforward.