Update commit status on successful / failed deployment #1671
Replies: 5 comments
|
Would love to see this in a future |
|
Any update on this? |
|
I managed to do it with a post deployment command (partially, it only calls the deployment api with success) Human readable version: # Update the package list and install jq
apt update && apt install -y jq
# Create a deployment on GitHub and capture the deployment ID
DEPLOYMENT_ID=$(curl -s \
-X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/<REPO_OWNER>/<REPO>/deployments \
-d '{
"ref": "main",
"environment": "production",
"description": "Finalizing deployment",
"auto_merge": false,
"required_contexts": []
}' | jq -r ".id")
# Check if the deployment creation failed
if [ -z "$DEPLOYMENT_ID" ] || [ "$DEPLOYMENT_ID" = "null" ]; then
echo "Failed to create deployment on GitHub"
exit 1
fi
# Post a successful deployment status to GitHub
curl -s \
-X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/<REPO_OWNER>/<REPO>/deployments/$DEPLOYMENT_ID/statuses \
-d '{
"state": "success",
"description": "Deployment completed successfully",
"environment_url": "<YOUR_ENDPOINT_URL>",
}'one-liner version to paste directly into the Post-deployment input area inside your Project->Configuration apt update && apt install -y jq && DEPLOYMENT_ID=$(curl -s -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" https://api.github.com/repos/<REPO_OWNER>/<REPO>/deployments -d "{\"ref\": \"main\", \"environment\": \"production\", \"description\": \"Finalizing deployment\", \"auto_merge\": false, \"required_contexts\": []}" | jq -r ".id") && [ -z "$DEPLOYMENT_ID" ] || [ "$DEPLOYMENT_ID" = "null" ] && echo "Failed to create deployment on GitHub" && exit 1 || curl -s -X POST -H "Authorization: Bearer $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" https://api.github.com/repos/<REPO_OWNER>/<REPO>/deployments/$DEPLOYMENT_ID/statuses -d "{\"state\": \"success\", \"description\": \"Deployment completed successfully\", \"environment_url\": \"<YOUR_ENDPOINT_URL>"}"Change:
Get an access token from Github settings -> developer settings ... and add it to your environment variables as $GITHUB_TOKEN. I couldn't find a way to get if the deployment was success or not so I only call the api with success. |
|
Summary Add native GitHub commit status updates to Coolify, so deployment status (pending, success, failure) is automatically shown on commits and pull requests, similar to Laravel Forge, Vercel, Netlify, and Railway. Problem When deploying applications connected to GitHub, users have no visibility into deployment status directly from GitHub. They must: Open the Coolify dashboard in a separate tab Navigate to the specific application Check deployment logs manually This creates friction, especially when: Reviewing pull requests, with no indication if preview deployment succeeded Monitoring main branch deployments Working in teams where not everyone has Coolify access Proposed Solution Automatically update GitHub commit status when deploying GitHub-connected applications. Status Flow Deployment Queued -> pending (yellow, Coolify: Deployment queued) Visual Example (GitHub PR) All checks have passed Coolify Production Deployed successfully 2m ago Implementation Approach If Coolify is installed as a GitHub App, it already has the necessary permissions. Add commit status updates to the deployment pipeline. Pseudo-code example: class DeploymentStatusNotifier } private function getContext(Deployment deployment): string private function getDescription(Deployment deployment, string state): string } Option B: Personal Access Token (Fallback) For users who connect via PAT instead of GitHub App, allow optional configuration. Example application settings: github_status_updates: Configuration UI Application Settings -> GitHub Repository: myorg/myrepo Update commit status on deployment Require successful deployment for PR merge Required GitHub Permissions For GitHub App: For PAT: Events to Hook Event: ApplicationDeploymentJob handle start Event: Docker build complete Event: Health check passed Event: Any exception caught Event: Job timeout Event: Manual cancellation Benefits Better developer experience with deployment status visible directly in GitHub Improved PR review workflow with preview deployment visibility Team-wide visibility without requiring Coolify access Enables GitHub branch protection with deployment gates Feature parity with Vercel, Netlify, Railway, Render, and Forge Alternatives Considered Users can create a workflow that triggers a Coolify webhook, polls the Coolify API for status, and updates GitHub commit status. Drawbacks: Requires extra secrets management Consumes GitHub Actions minutes Polling is less reliable than native integration High setup complexity for many users GitHub Check Runs API More powerful than commit statuses, but requires GitHub App only and is more complex to implement. Commit statuses are sufficient for this use case. Prior Art Vercel: Commit Status yes, Check Runs yes, PR Comments yes Success Metrics Reduced context switching for developers Faster PR review cycles Increased team adoption of Coolify Ability to enforce deployment gates via GitHub branch protection Additional Context There is an existing third-party implementation demonstrating this concept at github.com/mascarock/coolify-deployment-status, and this is a common request across deployment platforms. Mockups GitHub Commit View Commit abc123f Add new feature Status checks GitHub PR Checks Some checks have not completed yet Coolify / preview Deploying In progress Related: This pairs well with a Dynamic Favicon Badge feature that shows deployment status in the browser tab. |

Uh oh!
There was an error while loading. Please reload this page.
I was thinking it could be very helpful if Coolify updated the commit status shown in GitHub. This is something that many CI playforms do (like GitHub Actions and Jenkins) as well as CD platforms (such as Vercel).
Basically what it does is add a check or cross icon to the commit if the deployment was successful or failed respectively. Something Vercel does is also comment on the commit, I don't think this is needed as it introduces email spam (so if it can be turned off it's fine). But something like those notifications can be discussed in this other discussion: #503
Why is this helpful?
Well you do not want your entire team to have access to your Coolify instance, but it is important for them to know if their latest commit was deployed to production for example.
I think it can be updated using a GitHub App. Here is some information about how to implement this using the REST API: https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28
All reactions