I have a website hooked up with Deploy Previews built on every Pull Request in GitHub. I also already have automated tests running in Travis CI, one of which is building the website to test that it builds ok. Is there a way to have Travis push the compiled site to Netlify to publish as a branch Deploy Preview so Netlify doesn’t have to re-build the site again? I haven’t found a guide for specifically that sequence of events yet.
That’ll be tough - we intend people to EITHER deploy via our CI, or not, on a single netlify site. So, I guess you could create a second site, and push to it from travis? You’d use
netlify deploy from our CLI utility: https://github.com/netlify/cli directly from travis, and no need to rebuild here.
You could also do a slightly more convoluted workflow where you commit to git from travis, including a netlify.toml with a different configuration (no build command, possibly a different “publish” directory), and we could “deploy from git” (via that commit), without building (which is what happens when you link git, but specify no build command - we deploy the files directly). This should work today on a single site but feels a bit suboptimal.
Let me know what you think; might be worth opening up a feature request to “allow” manual deploys + git deploys from a site upon specific config, but we literally just turned that off to prevent folks who get access to your Netlify admin UI somehow (steal a password or auth token) from publishing manually, if there is a repo connected to the site, so it will take some discussion to find the right balance of protection and enabling your workflow, so please don’t hesitate to go into detail about your mixed-use desires to help us create the best use case. Alternatively, please do let me know if you would rather JUST deploy from Travis, in which case we can unhook the repo here and let you
netlify deploy and
netlify deploy --prod all day long on the main site~
Thanks for the reply! I was looking into the CLI to do it, but it didn’t seem like it supported being able to make Deploy Previews. Seemed like I’d have to manually make new sites for each PR to publish. I’ll re-read though, maybe I missed something.
For workflow, I’m actually only using this site for Deploy Previews and staging, so maybe
netlify deploy /
netlify deploy --prod will work for me. Running that at the end of a Travis job, will the Netlify PR check still show up in GitHub with the Deploy Preview URL? That’s very convenient for my team. We’re using the Deploy Preview as part of our code review process to make sure the code does what it says it does.
The CLI doesn’t know anything about PR’s - it is just “deploy these assets”. You can build anything you want - including from a PR - and run
netlify deploy with it. It won’t be CALLED a deploy preview (which builds of PR’s from git are), but it is still a previewable deploy
No git checks will be triggered with a CLI deploy. All of those git-related features, require a git backed build on our CI.