Create a separate trigger for publishing

I disabled auto-publishing because I want to publish manually. However, Netlify still auto-builds each commit, which is fine.

The problem is: I need to be able to tell the difference in my trigger functions when a commit is built vs if it’s deployed.

Right now, Netlify calls deploy-succeeded even if auto-publishing is disabled. It should be called build-succeeded and my suggestion is to create another trigger called build-deployed.

Good suggestion, but I do not think we’ll implement it soon. You can check the status of autopublishing via API call, so I’d suggest that in your deploy-succeeded function, you check that status (you’ll have the deploy ID; if it is in $CONTEXT == production, you would make an API call to see if the currently published deploy is this new ID or not), and then you can react appropriately in that code.

I have passed this feedback on to our product team, but as I mentioned, I think you’ll want to build something using our existing functionality to address your concern for now. If you can’t manage to get a flow that works as I described set up, let me know and I should be able to help you get something dialed in.

question: does the deploy-succeeded trigger fire twice, once for build, once for commit, if auto-publish is off?
if not, i.e. it only fires once, when the build succeeds, then I’ll never get a chance to run my “on publish” code.

no, deploy-succeeded (assuming here that we are talking about the event-triggered function) should fire after the deploy succeeds, and only then. A git commit is not a successful deploy (and won’t even trigger one if you have for instance:

Put another way, only completing a deploy (one that shows success in our logs) would be expected to trigger that event-triggered function.

If you want to do something only on publish, you will indeed have to build it in the way I described - likely, run some API calls after each deploy, to determine which one is published. But, I could also imagine a workflow that caused a date-published.txt file to be included with the prod deploy, and you polling it to see when things changed if you wanted to back into it a bit rather than stitching together a system to process the notification (I’d use myself).

If you have auto-publishing disabled, and change what is published (which you’d have to do manually), note that disabling and re-enabling publishing does send additional alerts. So perhaps if you are looking for the easiest way to build a workflow that is only triggered for published, locked deploys - you might be able to work from that specific notification, as a signal that will take less processing to be sure it is a “relevant, published” deploy: Deploy notifications | Netlify Docs