Triggered site builds
When the site repository is separate from the data repository, there can be a long delay before changes to data appear on the site. This is because the change to the data only triggers a data rebuild, but the site will not change until it is rebuilt. Out of the box, site rebuilds only happen during the nightly build, and whenever a file in the site repository is changed.
This means that, in order to see their updated data on the site, data managers must either:
- Wait until the next day, or
- Change a site file to trigger a site build
To solve this problem, the following steps can be taken to set up an automatic site rebuild whenever the data changes.
Creating an access token¶
- Create an access token described in this official GitHub documentation. Notes:
- Select the
repo
permission, as indicated in those instructions. - Save the token somewhere private.
- Select the
- Copy the access token so that you can paste in the next steps.
Adding the access token as a "secret"¶
- Go to the site repository.
- Under the repository name, click "Settings".
- In the left sidebar, click "Secrets".
- Click "New repository secret".
- Under "Name", type the following (case-sensitive):
token
- Under "Value", paste in the access token you copied earlier.
- Click the green "Add secret" button.
Then repeat this for the data repository, as follows:
- Go to the data repository.
- Under the repository name, click "Settings".
- In the left sidebar, click "Secrets".
- Click "New repository secret".
- Under "Name", type the following (case-sensitive):
token
- Under "Value", paste in the access token you copied earlier.
- Click the green "Add secret" button.
Configuring the automatic rebuild¶
- In the list of files in the data repository, click on
.github/workflows
. - Click on
deploy-to-staging.yml
. - Click the pencil to edit the file.
- Make changes to the file by following the instructions in the notes.
- Towards the right, click "Start commit"
- Select "Create a new branch for this commit and start a pull request."
- Beneath this, click "Propose changes".
- Click on the green "Create pull request" button.
- Wait a moment to see the message that says "Test PRs / test (pull_request) - in progress"
- Wait until you see "All checks have passed". This takes about 5 minutes.
- Click on the green "Merge pull request" button.