Configure GitHub¶
This documentation includes workflows for automatically updating dependencies. To make them work, you need to allow the automated creation and approval of pull requests in GitHub, configure auto-merge, and set up automated checks. The workflows authenticate as a GitHub App, so that the created pull requests trigger subsequent workflows (which the default GITHUB_TOKEN cannot do) and commits are authored by the bot account.
Allow automated PRs¶
In your GitHub repository:
- Go to Settings, Actions, General. Scroll to the bottom.
-
Set:
- Allow GitHub Actions to create and approve pull requests:
yes
- Allow GitHub Actions to create and approve pull requests:
-
Click Save.
Require status checks¶
This requires status checks to succeed, before (automated or manual) PRs are auto-merged.
This setting is recommended but not required
If the following is not configured, PRs created by the GitHub workflow are automatically merged without verifying that they build correctly.
In your GitHub repository:
- Go to Settings, Branches.
- Click Add classic branch protection rule to create a new branch protection rule.
-
Set:
- Branch name pattern:
main - Protect matching branches
- Require status checks to pass before merging:
yes
- Require branches to be up to date before merging:
yes
- Status checks that are required:
Build Documentation
- Require branches to be up to date before merging:
- Require status checks to pass before merging:
- Branch name pattern:
-
Click Save changes.
Enable auto-merge¶
In your GitHub repository:
- Go to Settings, General. Scroll down to the Pull Requests section.
-
Set:
- Allow auto-merge:
yes
- Allow auto-merge:
Create a GitHub App¶
By design, workflows that use the GITHUB_TOKEN will not trigger new workflow runs, to avoid recursive workflow runs. This means that the status checks will not automatically run for the PRs created by the workflow. To fix this, the workflows authenticate as a GitHub App instead of using the GITHUB_TOKEN. Commits and PRs created by the App show up as authored by the bot account, and the App's commits are signed by GitHub and show as Verified.
- In your GitHub profile, go to Settings, Developer settings, GitHub Apps (or click here).
-
Click New GitHub App. Give the following values:
- GitHub App name:
Virtlink Bot - Homepage URL:
https://pelsmaeker.net/ - Webhook
- Active:
disabled
- Active:
- Repository permissions
- Contents: Read and write
- Pull requests: Read and write
- Issues: Read and write
- Metadata: Read-only (required)
- Workflows: Read and write
- Where can this GitHub App be installed? Only on this account
Workflow permission
The Workflows permission is required because the Update GitHub Actions workflow uses Renovate to update the versions of the GitHub Actions referenced in the workflow files themselves. Without this permission, GitHub rejects any push that modifies files under
.github/workflows/. - GitHub App name:
-
Click Create GitHub App.
- Under Private keys, click Generate a private key and download the
.pemfile. Keep it safe, as you will not be able to download it again. - Determine the App ID (found at the top under About).
Install the GitHub App¶
In the GitHub App settings, click Install App and click the Install button next to the account to install the bot to. You can restrict the App to specific repositories.
Configure the repository to use the GitHub App¶
In the GitHub repository:
- Go to Settings, Secrets and variables, Actions.
- On the Secrets tab, under Repository secrets, click New repository secret.
-
Add the following secret:
- Name:
APP_ID - Secret: the App ID of the GitHub App
- Name:
-
Click Add secret.
-
Click New repository secret again, and add:
- Name:
APP_PRIVATE_KEY - Secret: the entire contents of the
.pemfile (the App's private key)
- Name:
-
Click Add secret.
The workflows already use the APP_ID and APP_PRIVATE_KEY secrets to generate an App token, so no further changes to the workflows are needed.