Skip to content

Commit 62a2223

Browse files
authored
docs: GA contributing update with additional ci and repository secret preparation. (#319)
1 parent 7074be6 commit 62a2223

1 file changed

Lines changed: 108 additions & 3 deletions

File tree

content/CONTRIBUTING.md

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ And if you like the project, but just don't have time to contribute, that's fine
2626
- [Pull Requests](#pull-requests)
2727
- [How to test incoming changes](#how-to-test-incoming-changes)
2828
- [Building with GitHub Actions (recommended)](#building-ga)
29+
- [Setting up your test build branch](#test-branch-ga)
30+
- [Preparing Image and Kernel signing key](#signing-keys-ga)
31+
- [Preparing GitHub Actions CI Workflow](#workflow-ga)
32+
- [Recommended Git Workflow for Pull Requests](#workflow-git)
33+
- [Building and Rebasing to your Image Repository](#rebase-ga)
2934
- [Building Locally](#building-locally)
3035
- [Styleguides](#styleguides)
3136
- [Commit Messages](#commit-messages)
@@ -92,12 +97,112 @@ We strive towards a model where proposed changes are more thoroughly reviewed an
9297
## [Building with GitHub Actions (recommended)](#building-ga)
9398
{: #building-ga}
9499

95-
Start from your own fork with a branch for the pull request/feature you want to develop. Follow the instructions [here](https://blue-build.org/how-to/cosign/) to add your own keys to verify your own custom image. From there, it's recommended you go to .github/workflows/build.yml and comment out all of the image variants except the ones you use/intend to test. This drastically speeds up your workflow runtime. Then just go to actions > build-secureblue and select run workflow, making sure you select the branch you just set up.
100+
Building with GitHub Actions allows you to create your own bootable images to rebase your Fedora Atomic installation to in order to test pull requests/features you are developing.
96101

97-
Once it's done building, go to your VM running Fedora Atomic and rebase to your newly built image. This is a string that starts with 'rpm-ostree rebase ostree-unverified-registry:ghcr.io/', followed by the repo and package name. This can be found by checking the "packages" section in the sidebar of your fork. Take the docker pull command and copy the repo and package reference. Then, append the tag, which is in the format `br-{branchName}-{fedoraVersion}`. Your command should look like this:
102+
### [Setting up your test build branch](#test-branch-ga)
103+
{: #test-branch-ga}
104+
105+
Start from your own fork with a branch for building your images. It is recommended to keep the branch you want to build your images from separate from branches you want to create pull requests from to keep the changes to your workflow separate from your feature changes and avoid merge conflicts. You can create a build branch called `test-build` by doing the following:
106+
107+
```sh
108+
# Add upstream remote if wasn't already added
109+
git remote add upstream https://github.com/secureblue/secureblue
110+
111+
# Fetch latest changes from upstream/live
112+
git fetch upstream live
113+
114+
# Create your test-build branch based on upstream/live
115+
git switch -c test-build upstream/live
116+
```
117+
118+
### [Preparing Image and Kernel signing key](#signing-keys-ga)
119+
{: #signing-keys-ga}
120+
121+
Follow the instructions [here](https://blue-build.org/how-to/cosign/) to add your own keys to verify your own custom image. Then create two copies of your your public singing key in `files/system/etc/pki/containers/` called `GITHUB_REPOSITORY_OWNER-2025.pub` and `GITHUB_REPOSITORY_OWNER.pub`.
122+
123+
You must also add a kernel signing key to your repository secrets for verifying kernel modules. [The kernel signing makes use of an X.509 certificate](https://www.kernel.org/doc/html/latest/admin-guide/module-signing.html), in which you can generate your own or use the test key pair provided in the repository. Note that the key pair in the repository is for test purposes only, as using it in production would allow the loading of malicious kernel modules that seem legitimate. If using the test key pair provided, first copy the private key `.github/workflows/private_key.priv.test` to a GitHub repository secret called `KERNEL_PRIVKEY` alongside your signing key you created to verify your public image. Then copy the public key `.github/workflows/pub_key.der.test` to `files/system/etc/pki/akmods/certs/`.
124+
125+
### [Preparing GitHub Actions CI Workflow](#workflow-ga)
126+
{: #workflow-ga}
127+
128+
To prepare the CI workflow in GitHub Actions, it's recommended you go to `.github/workflows/build-all.yml` and comment out all of the image variants except the ones you use/intend to test. For the images you haven't commented out, you must make sure to change the `github.triggering_actor` to the GitHub username that will trigger the workflow.
129+
130+
### [Recommended Git Workflow for Pull Requests](#workflow-git)
131+
{: #workflow-git}
132+
133+
This is a recommended git workflow you can adopt, assuming you've already [created a test build branch](#test-branch-ga) called `test-build` tracking the upstream secureblue repository.
134+
135+
Once all of your [signing keys](#signing-keys-ga) and [GitHub workflow](#workflow-ga) changes ready on `test-build`, commit your changes and create a tag called `test-build-setup` so we can use it later:
136+
137+
```sh
138+
git add .
139+
git commit -m "DO NOT MERGE: test-build setup"
140+
git tag -f test-build-setup
141+
git push origin test-build
142+
```
143+
144+
You then may want to create a branch for your pull request/feature based on `upstream/live`, for example:
145+
146+
```sh
147+
# Fetch latest changes from upstream/live
148+
git fetch upstream live
149+
git switch -c new-feature upstream/live
150+
151+
# ... Do the changes ...
152+
153+
git add .
154+
git commit -S -m "feat: ducks can now fly"
155+
git push origin new-feature
156+
```
157+
158+
Switch back to `test-build` and cherry pick or merge your changes from `new-feature`.
159+
160+
```sh
161+
git switch test-build
162+
git cherry-pick <hash> # Or simply 'git merge new-feature' for the full branch.
163+
git push origin test-build
164+
```
165+
166+
You may then go on to [build and rebase to your image](#rebase-ga) to test your pull request.
167+
168+
You can sync your build branch with upstream by doing the following:
169+
170+
```sh
171+
# Make sure we're on test-build
172+
git switch test-build
173+
174+
# Fetch latest changes from upstream/live
175+
git fetch upstream live
176+
177+
# Reset the branch to upstream/live
178+
git reset --hard upstream/live
179+
180+
# Cherry pick the tag defined before
181+
git cherry-pick test-build-setup
182+
183+
# ... Cherry pick or commit changes ...
184+
185+
# Push rewriting the history
186+
git push --force-with-lease origin test-build
187+
```
188+
189+
### [Building and Rebasing to your Image Repository](#rebase-ga)
190+
{: #rebase-ga}
191+
192+
Once everything is ready, go to **Actions** > **build** and select run workflow, making sure you select the branch you just set up.
193+
194+
Once it's done building, go to your VM running Fedora Atomic and rebase to your newly built image. If you're working from a secureblue image which rejects container images by default, make sure to [add your image registry to the container policy](/faq#container-policy). Your image registry is called `ghcr.io/YOURUSERNAME`.
195+
196+
To rebase to your image on your remote registry without a signature, your command will start with `rpm-ostree rebase ostree-unverified-registry:`, followed by the registry and package name. This can be found by checking the "packages" section in the sidebar of your fork. Take the docker pull command and copy the registry and package reference. Then, append the tag, which is in the format `br-{branchName}-{fedoraVersion}` (e.g. `br-test-build-43`) or just `latest` if it the image is built on your repository's default branch. If your image is not built on the default branch, your command should look like this:
197+
198+
```
199+
rpm-ostree rebase ostree-unverified-registry:ghcr.io/YOURUSERNAME/YOURIMAGENAME:br-YOURBRANCHNAME-FEDORAVERSION
200+
```
201+
202+
Likewise, on the default branch your command will look like this:
98203

99204
```
100-
rpm-ostree rebase ostree-unverified-registry:ghcr.io/YOURUSERNAME/YOURIMAGENAME:br-YOURBRANCHNAME-42
205+
rpm-ostree rebase ostree-unverified-registry:ghcr.io/YOURUSERNAME/YOURIMAGENAME:latest
101206
```
102207

103208
## [Building Locally](#building-locally)

0 commit comments

Comments
 (0)