Skip to content

Commit 8c61d35

Browse files
committed
Add podman-entitlement GitHub Action.
1 parent 009206a commit 8c61d35

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This repository contains the common Actions and config files for developing the
1212
- [action-io-generator](./action-io-generator) is an NPM package and (soon to be) Docker Action that makes sure your JavaScript action uses the same Inputs and Outputs defined in your `action.yml`.
1313
- [bundle-verifier](./bundle-verifier) is a JavaScript Action that makes sure your JavaScript action's committed distribution bundle is up-to-date.
1414
- [commit-data](./commit-data) is a Docker Action that outputs some commonly needed data about the current workflow's HEAD commit.
15+
- [podman-entitlement](./podman-entitlement) is a composite Action which enables subsequent `podman build`s to consume Red Hat entitlements.
1516
- [config-files](./config-files) contains our shared TypeScript, ESLint, and Webpack configs.
1617

1718
It is also used for tracking issues that don't fit into another, more specific repository.

podman-entitlement/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Podman Entitlement GitHub Action
2+
3+
When building container images that install Red Hat content
4+
which is not part of Universal Base Image repositories,
5+
Red Hat entitlements are needed to access the full Red Hat Enterprise Linux
6+
repositories.
7+
8+
To avoid modifying the Dockerfiles with extra steps that would
9+
handle the registration, this Action registers a temporary system
10+
using organization's activation key, and uses `/etc/containers/mounts.conf`
11+
to configure subsequent `podman build` invocations to have access
12+
to the entitlements.
13+
14+
## Inputs
15+
16+
| Input | Description |
17+
| --- | --- |
18+
| `org` | Red Hat account organization |
19+
| `activationkey` | Red Hat account activation key |
20+
| `image` | Container image to use to run `subscription-manager register` with the above parameters <br> Optional, defaults to `registry.access.redhat.com/ubi9` |
21+
22+
## Usage
23+
24+
On https://access.redhat.com/management/activation_keys, create
25+
new Subscription Manager activation key.
26+
27+
Set up secrets in your repository, for example `redhat_org` for your
28+
Red Hat account organization and `redhat_activationkey` for your Red Hat
29+
account activation key. Your Organization ID is shown on the above-mentioned
30+
Activation Keys page on Red Hat portal.
31+
32+
In your workflow YAML which calls `podman build`, add invocation
33+
of `redhat-actions/common/podman-entitlement` before that `podman build`
34+
step:
35+
36+
```yaml
37+
- uses: redhat-actions/common/podman-entitlement
38+
with:
39+
org: ${{ secrets.redhat_org }}
40+
activationkey: ${{ secrets.redhat_activationkey }}
41+
- run: podman build -t localhost/the-image:the-tag src
42+
```
43+

podman-entitlement/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Enable Red Hat entitled podman builds'
2+
inputs:
3+
org:
4+
description: 'Red Hat account organization'
5+
activationkey:
6+
description: 'Red Hat account activation key'
7+
image:
8+
description: 'Container image to use to run subscription-manager register'
9+
default: 'registry.access.redhat.com/ubi9'
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- run: |
14+
NAME="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
15+
NAME="${NAME#https://}"
16+
NAME="${NAME////-}"
17+
EDIR=/tmp/etc-pki-entitlement-${{ github.run_id }}
18+
CDIR=/tmp/rhsm--${{ github.run_id }}
19+
rm -rf "$EDIR" "$CDIR"
20+
mkdir -p "$EDIR" "$CDIR"
21+
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'
22+
( echo "$EDIR:/run/secrets/etc-pki-entitlement" ; echo "$CDIR:/run/secrets/rhsm" ) | sudo tee /etc/containers/mounts.conf
23+
shell: bash

0 commit comments

Comments
 (0)