|
| 1 | +# Reference: https://github.com/redhat-cop/redhat-image-mode-actions |
| 2 | +name: Build RHEL bootc image |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + containerfile: |
| 7 | + type: string |
| 8 | + required: true |
| 9 | + dest-image: |
| 10 | + type: string |
| 11 | + required: true |
| 12 | + tag-list: |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + runs-on: |
| 16 | + type: string |
| 17 | + default: ubuntu-24.04-arm |
| 18 | + |
| 19 | +jobs: |
| 20 | + rhel-bootc-image-build: |
| 21 | + name: Build RHEL bootc image |
| 22 | + runs-on: ${{ inputs.runs-on }} |
| 23 | + env: |
| 24 | + # Disable Subscription Manager container passthrough |
| 25 | + SMDEV_CONTAINER_OFF: 1 |
| 26 | + |
| 27 | + # Source registry for base image |
| 28 | + SOURCE_REGISTRY_HOST: "registry.redhat.io" |
| 29 | + |
| 30 | + # Destination registry for built images |
| 31 | + DEST_REGISTRY_HOST: "quay.io" |
| 32 | + |
| 33 | + # Destination image namespace and name (eg: myrepo/myimage) |
| 34 | + DEST_IMAGE: ${{ inputs.dest-image }} |
| 35 | + |
| 36 | + # List of tags to publish |
| 37 | + TAGLIST: ${{ inputs.tag-list }} |
| 38 | + |
| 39 | + # Containerfile to build |
| 40 | + CONTAINERFILE: ${{ inputs.containerfile }} |
| 41 | + |
| 42 | + container: |
| 43 | + image: registry.access.redhat.com/ubi9/ubi |
| 44 | + options: --privileged |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + packages: write |
| 48 | + |
| 49 | + steps: |
| 50 | + - name: Clone the repository |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Get container tools in UBI builder |
| 54 | + run: dnf -y install podman buildah skopeo |
| 55 | + |
| 56 | + - name: Access a subscription via activation key |
| 57 | + run: subscription-manager register --org=${{ secrets.RHT_ORGID }} --activationkey=${{ secrets.RHT_ACT_KEY }} |
| 58 | + |
| 59 | + # workaround for https://github.com/redhat-actions/podman-login/issues/42 since the docker config from the host doesn't come up to the container |
| 60 | + - name: Workaround open podman-login action issue |
| 61 | + env: |
| 62 | + auth: "{ \"auths\": {} }" |
| 63 | + run: | |
| 64 | + mkdir -p $HOME/.docker |
| 65 | + echo $auth > $HOME/.docker/config.json |
| 66 | +
|
| 67 | + - name: Log in to the RHT terms based registry |
| 68 | + uses: redhat-actions/podman-login@v1 |
| 69 | + with: |
| 70 | + registry: ${{ env.SOURCE_REGISTRY_HOST }} |
| 71 | + username: ${{ secrets.SOURCE_REGISTRY_USER }} |
| 72 | + password: ${{ secrets.SOURCE_REGISTRY_PASSWORD }} |
| 73 | + auth_file_path: /run/containers/0/auth.json |
| 74 | + |
| 75 | + - name: Use buildah bud to create the image |
| 76 | + id: build-image |
| 77 | + uses: redhat-actions/buildah-build@v2 |
| 78 | + with: |
| 79 | + image: ${{ env.DEST_IMAGE }} |
| 80 | + tags: ${{ env.TAGLIST }} |
| 81 | + containerfiles: ${{ env.CONTAINERFILE }} |
| 82 | + |
| 83 | + - name: Log in to the Container registry |
| 84 | + uses: redhat-actions/podman-login@v1 |
| 85 | + with: |
| 86 | + registry: ${{ env.DEST_REGISTRY_HOST }} |
| 87 | + username: ${{ secrets.DEST_REGISTRY_USER }} |
| 88 | + password: ${{ secrets.DEST_REGISTRY_PASSWORD }} |
| 89 | + auth_file_path: /run/containers/0/auth.json |
| 90 | + |
| 91 | + - name: Push to Container Repository |
| 92 | + id: push-to-ghcr |
| 93 | + uses: redhat-actions/push-to-registry@v2 |
| 94 | + with: |
| 95 | + image: ${{ steps.build-image.outputs.image }} |
| 96 | + tags: ${{ steps.build-image.outputs.tags }} |
| 97 | + registry: ${{ env.DEST_REGISTRY_HOST }} |
| 98 | + |
| 99 | + - name: Clean up the subscription |
| 100 | + if: always() |
| 101 | + run: subscription-manager unregister |
0 commit comments