Skip to content

How do I get notified when my Vercel deployment fails?

When your Vercel Deployment succeeds, you are notified with a comment in your Git repository that is also sent as an email notification based on your Git account settings. However, if your deployment fails, no comment is sent back to your Git account (and hence, you do not receive any notification). In this article, we present different ways in which you can find out if your deployment has failed.

Existing ways of checking for failed deployments

  1. If you look at the Git status for the submitted commit on the Git repository commits page, you will either see a checkmark (success) or cross (failed). If you click on the link for a particular commit, you will see comments from the Vercel bot for each successful or failed deployment.
  2. If you go to the project's Deployments page on your Vercel dashboard (Vercel Account > Project > Deployments), you will see the status of each deployment in the deployments list. Clicking on the specific deployment will bring you to the deployment's detail page that includes the Build logs where you can find the reason why a deployment may have failed.

Setting up notifications for failed deployments in Github

The above mentioned methods require that you manually check the appropriate pages to find out what happened. If you are using Github, you can use Github actions to run custom workflows based on deployment events and include an action that will add a comment based on a deployment failure. Thereafter, if you have the right notification settings and permissions, you will receive a notification for each Github action comment.

Set up the Github action workflow

To set up a Github action workflow, do the following in your Github repository:

  1. Create a .github folder in the root of your project.
  2. Create a workflows folder in the .github folder.
  3. Create a .yml file with the name of your worflow such as deploy-failed.yml in the workflows folder.
  4. Paste the code below (also available here) in your .yml file. If you decide to fork the linked repository and deploy it on Vercel, make sure that you set the Root Directory of your Vercel Project General Settings to src and that your Framework Preset is set to Next.js.
#Triggered for deployment status changes name: Deployment Failure notification on: [deployment_status] jobs: add-failure-comment: name: Add a comment to the commit that caused the failure if: github.event.deployment_status.state == 'failure' runs-on: ubuntu-latest steps: - name: Add commit comment - failure run: | curl -L -X POST \ --url${{ github.repository }}/commits/${{ github.sha }}/comments \ --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ --header 'content-type: application/json' \ --data '{ "body": "Deployment has failed." }'

Github action workflow yaml code

Once you have pushed these changes, ensure that you go to the Actions tab of your Github repository in the web browser to enable the workflow. This is specially important if you forked the repository containing the .yml file. For security reasons, Github will disable any workflow from a repository that was forked.

Set up notifications

In order to receive an email every time the Github action is triggered due to a deployment failure, check the following:

  • Ensure that Email is checked in the Watching section of your Github account settings here.
  • Check that you are watching the repository in question.
  • Check which Default notification email is set on the same page.
  • You can also set different emails for each organization.

You can now make a test push to your code that will cause a deployment failure and you should receive an email within a few minutes of the failure from with in the email body Deployment has failed.

Couldn't find the guide you need?