A GitHub App that deploys a PR branch to a static website when you ask it to.
Websites are served by a Google Cloud Storage bucket.
This app runs on an instance of Google AppEngine and is installed exclusively on ampproject/amphtml.
- A commit is pushed to a new or existing pull request on ampproject/amphtml.
- Travis compiles your changes and uploads the build artifacts and example pages as
amp_dist_<Travis build number>.zipto a remote storage location. During this step, a check calledampproject/pr-deployis set topending. - a) If there was a compilation error, Travis tells the AMP PR Deploy Bot that there's nothing left to do until the error is fixed.
b) If there were no errors, Travis tells the AMP PR Deploy Bot that a test site is ready to be deployed.ampproject/pr-deployis nownetural - A test site is deployed by clicking the 'Deploy Me' button in the details page of
ampproject/pr-deploy. The app unzips and writesamp_dist_<Travis build number>.zipto the public Google Cloud Storage bucket. ampproject/pr-deploycompletes with the website URL.https://console.cloud.google.com/storage/browser/amp-test-website-1/amp_dist_<Travis build number>
Here's a quick demo on how to create a test site.
- Clone this repository and cd into the
pr-deploydirectory. npm install- Start a new Smee channel. This can be used to proxy GitHub webhooks to your local machine.
- Create a new GitHub App with the following settings:
- General
- Set Homepage URL to the Smee channel
- Set Webhook URL to the Smee channel
- Set Webhook Secret to any pin your choice
- Permissions and Events
- Set Checks to Read & write
- Set Metadata to Read-only
- Set Pull requests to Read-only
- Subscribe to events: Check run, Pull request
- General
- After creating the application, generate and download a private key. Also take note of the App ID.
- Create a personal access token belonging to a GitHub user with the
public_repoandread:orgpermissions and note its access token. - Install the application on a GitHub repository that you want to use for testing. You might want to fork the ampproject/amphtml repository or create a new repository for this purpose.
- Copy the
.env.examplefile to.envand modify the fields based on the instructions in that file and the values from the GitHub App page:- The value for the
PRIVATE_KEYfield is a base64 representation of the.pemfile you downloaded from the GitHub App page in Step 5. On Linux/Mac you can convert that file by runningcat private-key-file.pem | base64in a command line. - The value for the
APP_IDfield is the App ID from Step 5. - The value for the
INSTALLATION_IDcan be found when callingGET /repos/:owner/:repo/installation, as seen in the GitHub App docs
- The value for the
npm run dev
If there are no errors after running the last command then the app is running locally on your machine.
This GitHub App is deployed on an AppEngine instance: https://amp-pr-deploy-bot.appspot.com