Now for GitHub is an app for GitHub users or organizations that automatically deploys and aliases changes to repositories with ZEIT Now.
The Now for GitHub integration features:
- Deploys every push in branches and pull requests to preview changes live
- Aliases the most recent changes from the master branch
- Instant rollbacks when reverting changes that have been aliased
Connecting the App to Your GitHub Account or Organization
Now for GitHub is directly connected with your ZEIT account and can be linked from within your account or team settings. Within the settings page under the "General" tab, the first section will offer for you to install Now for GitHub if it is not already installed.
If you are a new user signing up, this process can also be started from within the onboarding stage.
Clicking the Install Now for GitHub button will take you to GitHub where they will prompt you, if you have an account belonging to any organizations, which profile the installation should be installed with. You can pick either your GitHub account or any of the organizations you have access to.
If you are not part of any organization, you will skip straight to the repository selection.
For organizations that you have limited permissions for, GitHub will ask you to request access to install the integration. Once requested, the organization's owner will need to approve the integration.
With an account or organization selected, GitHub will now ask for which repositories Now for GitHub should work with. In this step you are able to allow all repositories to be deployed or an optional set of repositories.
With the GitHub profile and repositories chosen for Now for GitHub to work with, the application will be ready to start using. The next step is to prepare the repository to be deployed with ZEIT Now.
Default Behavior
A Deployment for Each Push
Now for GitHub will deploy every push by default. This includes pushes and pull requests made to branches. This allows those working within the repository to preview changes made before the changes are pushed to production.
With each new push, if Now is already building a previous commit, Now will cancel that current build to start the most recent commit so that you always have the latest changes deployed as quickly as possible.
Aliasing the Default Branch
If an alias is set from the project domains dashboard, pushes and merges to the default branch (commonly "master") will be aliased automatically and made live to those aliases with the latest deployment made with a push.
If you decide to revert a commit that has already been aliased, the previous commit's deployment will automatically be aliased instantly; providing you with instant rollbacks.
Staging Aliases for the Latest Changes for Each Pull Request
The latest push to any pull request will automatically be aliased to a unique URL based on the project name, branch, and team or username. These URLs will be given through a comment on each pull request. For more on automatic aliases for git pushes and beyond in the Aliasing Documentation.
Deployment Authorizations for Forks
If you receive a pull request from a fork of your repository and there is either a change to the now.json
file or there are secrets used in your project; Now will require an authorization from you or a member of your team to deploy the pull request.
This behavior protects you and your project from a leak of sensitive information.
Extending Your GitHub Workflow
Now for GitHub uses the deployment API to bring you an extended user interface both in GitHub, when showing deployments, and Slack, if you have notifications setup using the Slack GitHub app.
You will see all of your deployments, production or staging, from within GitHub in its own page. See the page for this very documentation: https://github.com/zeit/docs/deployments
Due to using GitHub's Deployments API, you will also be able to integrate with other services through GitHub's checks. Now for GitHub will provide the deployment URL to the checks that require it, for example; to a testing suite such as Ghost Inspector.
Configuration
Disabling Auto-Aliasing
To prevent Now from automatically aliasing the default branch to any alias setup within the now.json
file, use the following configuration option.
{ "github": { "autoAlias": false } }
Disable Commenting with Silent Mode
To prevent Now from commenting on pull requests and commits, use the following configuration option in a now.json
file for the repository you want to stop this behavior in.
{ "github": { "silent": true } }
Disable Auto Job Cancellation
To prevent Now from canceling in-progress builds to prioritise building newer commits, use the following configuration option in a now.json
file for the repository that this behavior should exist in.
{ "github": { "autoJobCancelation": false } }
Included Environment Variables
You may want to use different workflows and use different APIs based on Git information.
In order to support that, ZEIT Now will deploy your app with following built-in environment variables.
Variable Key | Description |
---|---|
NOW_GITHUB_DEPLOYMENT | An indicator for whether the app was deployed by Now for GitHub. |
NOW_GITHUB_ORG | The GitHub organisation who the app belongs to. |
NOW_GITHUB_REPO | The origin repository of the app. |
NOW_GITHUB_COMMIT_ORG | The organisation of which the commit belongs. For example, when submitting a pull request from a forked repository. |
NOW_GITHUB_COMMIT_REPO | The repository of which the commit belongs. For example, when submitting a pull request from a forked repository. |
NOW_GITHUB_COMMIT_REF | The branch that the app was deployed using. |
NOW_GITHUB_COMMIT_SHA | The sha of the commit the app was deployed using. |
NOW_GITHUB_COMMIT_AUTHOR_LOGIN | The username belonging to the author of the commit that the project was deployed using. |
NOW_GITHUB_COMMIT_AUTHOR_NAME | The name belonging to the author of the commit that the project was deployed using. |