Home
Support Forums

Is it possible to control when a deploy previews / deployment is created?

The topic question may not accurately reflect what I’m trying to do so apologises for that!

My use case is fairly simple, I want to be able to create an isolated environment for each pull request made and generate a deploy preview.

Assuming I have 2 services that are used together:

  1. Backend API - Deployed as a lambda function with a generated url
  2. Frontend (React) - Deployed to netlify

And assuming that the Frontend needs the Backend generated url to call it later on.

So our CI process looks like:

  1. Build the backend
  2. Get output from step 1 (which will be the backend url)
  3. export API_URL as env variable in the build step for the frontend
  4. Build frontend

As you can tell there is a reliance on one build step output in the next, this is doable for regular deployments (production and branch deploys). But it seems like there isn’t a way to do this for deploy previews. Because as far as I understand you can’t manually create deploy previews because it needs to have a reference to the commit, is there perhaps a way to provide these?

The reason why we want deploy previews is mainly for the commenting, screen caps, video caps because it’s been very useful to us in lowering the barrier for collecting feedback.

Thanks in advance and let me know if anything is unclear!

Hi, @nathan. If I’m understanding the question, it can be summarized as this?

  • How do I use the deploy preview workflow but with manual deploys?

Is that the question? If so, you are correct that this isn’t supported at this time. However, we’d be happy to discuss here how you see that working and we can enter a feature request for that change?

However, if I have completely misunderstood the request, would you please explain in more detail what you are looking to do?

Hi @luke

Yes that’s essentially the question.

I’m using github actions to deploy our website and ideally there would either be a flag or env variable that says I want to deploy it as a preview app (of course I’d also supply some other important information like the pull request id, github token etc):

- name: Publish a preview application
      uses: netlify/actions/cli@master
      with:
        args: deploy --dir=site --preview #preview flag
      env:
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_PREVIEW_APP: true # or perhaps like this
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        NETLIFY_PR_ID: ${{ github.pr_id }}

Hi @nathan,

You can use Netlify CLI and run the command netlify deploy. It’s not completely same as a deploy preview, but it’s probably the closest you can get to use preview URLs with manual deploy.

Then, when you wish to update the production site, you can run netlify deploy --prod and that would do it.

Right but the point is I’d like the previews with FeaturePeak feature (the commenting etc)

Hey Nathan,

The premise is that a dedicated deploy preview, as we see it, is driven by GitHub pull requests and GitLab merge requests.

Therefore, if your deploy preview is “building too soon”, you may want to add [skip netlify] to the commit message and trigger another PR or merge request (without [skip netlify]) when you’ve performed the steps you need to take.

Hi Scott thanks for the answer but I think we’ve deviated from the problem and that’s my problem.

I understand we can use manual deployments but they don’t have the feature of gathering feedback from the browser.

Just to reiterate I don’t have an issue with manual deployments, I have an issue that they don’t have the feedback toolbar on the browser

Hi @nathan,

@Scott isn’t talking about manual deploys. :slight_smile:

He’s asking you to add [skip ci] or [skip netlify] anywhere in the commit message. When Netlify sees that text, it skips building for that commit. Thus, you can safely run your CI tasks and once you wish to deploy to Netlify, create another PR (from within the CI process) without that text in the commit message. Netlify will build for that commit and thus, you’d get what you want.

Ah ok I get what you’re saying. So my flow could look like this:

  1. Deploy API
  2. Once deployed create a commit without [skip ci] in the message
  3. This will trigger the preview app

But what I’d prefer is to include build variables in the CI for the preview app

Could you elaborate on what you mean exactly? What kind of variables?

I’m trying to include build environment variables for the deployment in the github action. The reason I’m doing it this way instead of letting Netlify handle it is because I need to provide different build variables (per pull request).

I’ve looked at adding environment variables in the preview environment programmatically but the problem is if I have 2+ preview environments trying to edit the same environment variable then it starts to become an issue.

Perhaps I’m not explaining it so well but my goal is to control deployments that have the feedback tool on the browser. And some issues I came across were

  1. How can I control build environment variables in the CI process
  2. Does deploying it manually (netlify deploy in the CI pipeline) give me the same thing as netlify deploying it (the feedback drawer)

Short answer is, you can’t. That’s the reason we were suggesting workarounds.

But if that’s not going to work for you either, sadly you’d have to give up either of the things - the feedback widget or the different pipeline.

I found the action: Netlify Actions · Actions · GitHub Marketplace · GitHub while debugging another thread. Not sure if it’ll help you, but worth a try.

Lastly, to contextualise your env vars (between deploy previews, branch deploys, production etc.), you could use a build plugin!