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:
Backend API - Deployed as a lambda function with a generated url
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:
Build the backend
Get output from step 1 (which will be the backend url)
export API_URL as env variable in the build step for the frontend
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?
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 }}
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.
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.
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.
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
How can I control build environment variables in the CI process
Does deploying it manually (netlify deploy in the CI pipeline) give me the same thing as netlify deploying it (the feedback drawer)