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.
- A CI build compiles your changes and uploads the build artifacts and example pages as
amp_nomodule_<commit SHA>.zip
to a remote storage location. During this step, a check calledampproject/pr-deploy
is set topending
. - a) If there was a compilation error, the CI build tells the AMP PR Deploy Bot that there's nothing left to do until the error is fixed.
b) If there were no errors, the CI build tells the AMP PR Deploy Bot that a test site is ready to be deployed.ampproject/pr-deploy
is 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_nomodule_<commit SHA>.zip
to the public Google Cloud Storage bucket. ampproject/pr-deploy
completes with the website URL.https://console.cloud.google.com/storage/browser/amp-test-website-1/amp_nomodule_<commit SHA>
Here's a quick demo on how to create a test site.
- Clone this repository and cd into the
pr-deploy
directory. 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_repo
andread:org
permissions 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.example
file to.env
and modify the fields based on the instructions in that file and the values from the GitHub App page:- The value for the
PRIVATE_KEY
field is a base64 representation of the.pem
file you downloaded from the GitHub App page in Step 5. On Linux/Mac you can convert that file by runningcat private-key-file.pem | base64
in a command line. - The value for the
APP_ID
field is the App ID from Step 5. - The value for the
INSTALLATION_ID
can 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