{"id":238128,"date":"2022-10-28T08:51:00","date_gmt":"2022-10-28T12:51:00","guid":{"rendered":"https:\/\/wordpress-756359-3782526.cloudwaysapps.com\/?p=238128"},"modified":"2024-09-21T04:53:25","modified_gmt":"2024-09-21T04:53:25","slug":"22-28-10-surge-deploy","status":"publish","type":"post","link":"https:\/\/www.travis-ci.com\/blog\/22-28-10-surge-deploy\/","title":{"rendered":"Deploying with Surge.sh"},"content":{"rendered":"\n<p>Got some static files? Travis CI can deploy your static files to Surge.sh after a successful build. Builds triggered from Pull Requests will never trigger a deploy, let\u2019s see how we can make this happen.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"environment-variables\">Environment variables<\/h2>\n\n\n\n<p>There will be to&nbsp;<code>env vars<\/code>&nbsp;you will need to add to Travis:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>SURGE_LOGIN<\/code>: Set it to the email address you use with Surge<\/li>\n\n\n\n<li><code>SURGE_TOKEN<\/code>: Set it to your login token (get it by doing a surge token)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configuration-of-travisyml\">Configuration of&nbsp;<code>.travis.yml<\/code><\/h2>\n\n\n\n<p>You\u2019ll want to add surge as deployment provider in&nbsp;<code>.travis.yml<\/code>. If your project folder is not the repo root you can set the deploy option project to define a path relative to repo root to deploy. If you do not have a CNAME file with the name of the domain to publish to you can set the deploy option domain with the domain to deploy to, so for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deploy:\n  provider: surge\n  project: .\/static\/\n  domain: example.surge.sh<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"generated-content\">Generated content<\/h2>\n\n\n\n<p>It is suggested that you generate your files during the script step or the before_deploy step.<\/p>\n\n\n\n<p>When generating files during the script step, an error results in a failed build, or when generating files during the before_deploy step, an error does not result in a failed build.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"branches\">Branches<\/h2>\n\n\n\n<p>By default, Travis CI will only deploy from your master branch. You can specify what branch to deploy from with the deploy option on:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deploy:\n  on:\n    branch: myProductionBranch<\/code><\/pre>\n\n\n\n<p>To deploy from all branches set the deploy-&gt;on option all_branches to true:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>deploy:\n  on:\n    all_branches: true<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>That\u2019s it you now know how to deploy to Surge using Travis. As always if you have any questions please reach out to me at&nbsp;<a href=\"mailto:montana@travis-ci.org\">montana@travis-ci.org<\/a>&nbsp;and I\u2019ll help you through this if you need it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Got some static files? Travis CI can deploy your static files to Surge.sh after a successful build. Builds triggered from Pull Requests will never trigger a deploy, let\u2019s see how we can make this happen. Environment variables There will be to&nbsp;env vars&nbsp;you will need to add to Travis: Configuration of&nbsp;.travis.yml You\u2019ll want to add surge [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_breakdance_hide_in_design_set":false,"_breakdance_tags":"","footnotes":""},"categories":[16],"tags":[7,19,20,5],"class_list":["post-238128","post","type-post","status-publish","format-standard","hentry","category-news","tag-community","tag-feature","tag-infrastructure","tag-news"],"_links":{"self":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/comments?post=238128"}],"version-history":[{"count":2,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238128\/revisions"}],"predecessor-version":[{"id":240071,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/posts\/238128\/revisions\/240071"}],"wp:attachment":[{"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/media?parent=238128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/categories?post=238128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.travis-ci.com\/wp-json\/wp\/v2\/tags?post=238128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}