-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use GitHub App & REST PUT API for updating version.sbt
This changes the way we authenticate and make the 1 or 2 updates to `version.sbt` required for a release. Before: * Authenticate as: default `github-actions` bot * version.sbt update method: Cherry-pick the commits created by sbt-release, then push them to GitHub using `git push`, with the default `github-actions` bot using its credentials to make the push After: * Authenticate as: `gu-scala-library-release` GitHub App - https://github.com/apps/gu-scala-library-release * version.sbt update method: GitHub REST API for Repository Contents (PUT /repos/{owner}/{repo}/contents/{path}) https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents Now we're not really specifying the whole commit, just the content change to one file. This has a few different benefits: * Addresses the need to coexist with our branch-protection rulesets, because GitHub Apps can be exempted from rules, as discussed in issue #5 * Produces `Verified` commits - the commits show up as `Verified` in the GitHub UI, and have a `gpgsig` header entry that is signed by GitHub itself, essentially GitHub attesting that the author of the commit authenticated with GitHub to perform the file update. https://git-scm.com/docs/signature-format#_commit_signatures https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification#signature-verification-for-bots https://blog.gitbutler.com/signing-commits-in-git-explained/#github-verification The commits now appear to be attributed to `gu-scala-library-release`, rather than, eg, '@rtyley using gha-scala-library-release-workflow' - it's a bit of shame that the person triggering the release is no longer so clearly visible, but it's probably less confusing. To compensate for that, the commit message itself has been updated to specifically state the responsible user.
- Loading branch information
Showing
6 changed files
with
186 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Setting up the GitHub App | ||
|
||
The GitHub App is used by the release workflow to perform actions on your repos, like creating releases and | ||
making PR comments. | ||
|
||
Each organisation that uses the release workflow will need to create their _own_ GitHub App. | ||
If `gha-scala-library-release-workflow` had its own server infrastructure, we could probably follow the more | ||
common model of a single GitHub App being used by many organisations, but instead we take advantage of all those | ||
free GitHub Actions minutes, so we need to pass the workflow the private key of the GitHub App so that it can | ||
authenticate as the GitHub App... therefore we must each have our own GitHub App, so that we don't share private keys. | ||
|
||
## 1. Create the GitHub App | ||
|
||
### GitHub App for a single user account | ||
|
||
You can just click this link to get taken to a pre-filled page to create a new GitHub App - you'll just need to | ||
customise the app name: | ||
|
||
https://github.com/settings/apps/new?name=scala-library-release&url=https://github.com/guardian/gha-scala-library-release-workflow&public=false&contents=write&pull-requests=write&webhook_active=false | ||
|
||
### GitHub App for an organisation account | ||
|
||
You can use the link above, but change the url so that it starts like this (the url query parameters stay the same), | ||
and replace `ORGANIZATION` with your organisation's name (eg `guardian`): | ||
|
||
https://github.com/organizations/ORGANIZATION/settings/apps/new | ||
|
||
## 2. Install the GitHub App | ||
|
||
Once your GitHub App is created, it'll be _owned_ by your organisation, but it'll still need to be _installed_ | ||
on your organisation. You can do this from the `Install App` tag on the GitHub App's settings page. For example, | ||
for the `guardian` organisation, and the `gu-scala-library-release` app, the URL would be: | ||
|
||
https://github.com/organizations/guardian/settings/apps/gu-scala-library-release/installations | ||
|
||
At this point, you need to decide whether to install the app for all repositories, or just for selected | ||
repositories. Selected repositories is better, as it limits the possible damage a rogue workflow could inflict - | ||
but you'll need make sure you add all relevant repositories to the list as they come along. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Organisation Setup | ||
|
||
These instructions are the initial setup for an organisation that's going to use `gha-scala-library-release-workflow`. | ||
When we say "organisation", we mean a GitHub organisation (like [github.com/guardian](https://github.com/guardian)), but | ||
these instructions more or less also apply to a single GitHub user account, if you want to set up your own personal | ||
repos to use this workflow. | ||
|
||
## 1. Set up the GitHub App | ||
|
||
See [Setting up the GitHub App](github-app.md) for details on how to create the necessary GitHub App. | ||
|
||
## 2. Create credentials | ||
|
||
See [Generating new credentials](credentials/generating-credentials.md) for details on how to create the necessary | ||
credentials, and [Supplying credentials](credentials/supplying-credentials.md) for how to store and supply them to | ||
your repos. | ||
|
||
## 3. Configure repos to use the release workflow | ||
|
||
See [Configuration](configuration.md) for details on how to configure your repos to use the release workflow. |