-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add podman-entitlement GitHub Action.
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
## Podman Entitlement GitHub Action | ||
|
||
When building container images that install Red Hat content | ||
which is not part of Universal Base Image repositories, | ||
Red Hat entitlements are needed to access the full Red Hat Enterprise Linux | ||
repositories. | ||
|
||
To avoid modifying the Dockerfiles with extra steps that would | ||
handle the registration, this Action registers a temporary system | ||
using organization's activation key, and uses `/etc/containers/mounts.conf` | ||
to configure subsequent `podman build` invocations to have access | ||
to the entitlements. | ||
|
||
## Inputs | ||
|
||
| Input | Description | | ||
| --- | --- | | ||
| `org` | Red Hat account organization | | ||
| `activationkey` | Red Hat account activation key | | ||
| `image` | Container image to use to run `subscription-manager register` with the above parameters <br> Optional, defaults to `registry.access.redhat.com/ubi9` | | ||
|
||
## Usage | ||
|
||
On https://access.redhat.com/management/activation_keys, create | ||
new Subscription Manager activation key. | ||
|
||
Set up secrets in your repository, for example `redhat_org` for your | ||
Red Hat account organization and `redhat_activationkey` for your Red Hat | ||
account activation key. Your Organization ID is shown on the above-mentioned | ||
Activation Keys page on Red Hat portal. | ||
|
||
In your workflow YAML which calls `podman build`, add invocation | ||
of `redhat-actions/common/podman-entitlement` before that `podman build` | ||
step: | ||
|
||
```yaml | ||
- uses: redhat-actions/common/podman-entitlement | ||
with: | ||
org: ${{ secrets.redhat_org }} | ||
activationkey: ${{ secrets.redhat_activationkey }} | ||
- run: podman build -t localhost/the-image:the-tag src | ||
``` | ||
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,23 @@ | ||
name: 'Enable Red Hat entitled podman builds' | ||
inputs: | ||
org: | ||
description: 'Red Hat account organization' | ||
activationkey: | ||
description: 'Red Hat account activation key' | ||
image: | ||
description: 'Container image to use to run subscription-manager register' | ||
default: 'registry.access.redhat.com/ubi9' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: | | ||
NAME="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
NAME="${NAME#https://}" | ||
NAME="${NAME////-}" | ||
EDIR=/tmp/etc-pki-entitlement-${{ github.run_id }} | ||
CDIR=/tmp/rhsm--${{ github.run_id }} | ||
rm -rf "$EDIR" "$CDIR" | ||
mkdir -p "$EDIR" "$CDIR" | ||
podman run --name="$NAME" -v "$EDIR":/etc/pki/entitlement-out:z -v "$CDIR":/etc/rhsm-out:z -e SMDEV_CONTAINER_OFF=1 --rm "${{ inputs.image }}" bash -c '/usr/sbin/subscription-manager register --org="${{ inputs.org }}" --activationkey="${{ inputs.activationkey }}" --name="'$NAME'" && cp /etc/pki/entitlement/* /etc/pki/entitlement-out/ && cp -r /etc/rhsm/ca /etc/rhsm/rhsm.conf /etc/rhsm-out && /usr/sbin/subscription-manager unregister' | ||
( echo "$EDIR:/run/secrets/etc-pki-entitlement" ; echo "$CDIR:/run/secrets/rhsm" ) | sudo tee /etc/containers/mounts.conf | ||
shell: bash |