Auto Deployment of Pull Requests on GitHub using Surge Technology

Published Jan 30, 2018

Open Source communities are being improved every day. Following every best practices in the organization, each pull request includes a working demo link of the fix. Currently, the demo link can also be generated by using GitHub pages. There is alternative to generate deployment link using Surge technology.

Surge is the technology which publishes or generates the static web-page demo link, which makes it easier for the developer to deploy their web-app. There are a lot of benefits of using surge over generating demo link using GitHub pages:

  • As soon as the pull request passes Travis CI, the deployment link is generated. It has been set up as such, no extra terminal commands will be required.
  • Faster loading compared to deployment link is generated using GitHub pages.

Surge can be used to deploy only static web pages. Static web pages mean websites that contain fixed contents.


To implement the feature of auto-deployment of pull request using surge, one can follow up these steps:

  • Create a file which will be executed during Travis CI testing.
  • The file can be executed after success i.e. when Travis CI passes by using command bash

The file looks like this:

 #!/usr/bin/env bash
 if [ “$TRAVIS_PULL_REQUEST” == “false” ]; then
 echo “Not a PR. Skipping surge deployment.”
 exit 0
 angular build production
 npm i -g surge

 # Token of a dummy account
 export SURGE_TOKEN=d1c28a7a75967cc2b4c852cca0d12206

 surge —project ./dist —domain $DEPLOY_DOMAIN;

Once file has been created, execute the file in the travis.yml by using command bash

In this way, I have integrated the surge technology for auto-deployment of the pull requests on GitHub. This can be done only with project based on Single Page Application.


  • Static web publishing for the Front-End developers:
Discover and read more posts from Harshit Prasad
get started