|
| 1 | +name: RHEL UBI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - .github/workflows/rhel-ubi.yml |
| 7 | + - docker/rhel-ubi/Dockerfile |
| 8 | + push: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + paths: |
| 12 | + - .github/workflows/rhel-ubi.yml |
| 13 | + - docker/rhel-ubi/Dockerfile |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +defaults: |
| 21 | + run: |
| 22 | + shell: bash |
| 23 | + |
| 24 | +env: |
| 25 | + PUSH: ${{ github.event_name == 'push' }} |
| 26 | + CONTAINER_REGISTRY: ghcr.io |
| 27 | + BUILDKIT_PROGRESS: plain |
| 28 | + |
| 29 | +jobs: |
| 30 | + # Build the Docker image for the Red Hat Enterprise Linux image based on their |
| 31 | + # free Universal Binary Image, which contains a subset of feature. We modify |
| 32 | + # this image by adding back a package repository that contains dependencies we |
| 33 | + # need. |
| 34 | + # Note, the `os` part of matrix must be kept in sync with the `merge` job below |
| 35 | + build: |
| 36 | + strategy: |
| 37 | + matrix: |
| 38 | + architecture: |
| 39 | + - platform: linux/amd64 |
| 40 | + runner: ubuntu-24.04 |
| 41 | + name: x86_64 |
| 42 | + - platform: linux/arm64 |
| 43 | + runner: ubuntu-24.04-arm |
| 44 | + name: aarch64 |
| 45 | + os: |
| 46 | + - release: 8 |
| 47 | + - release: 9 |
| 48 | + - release: 10 |
| 49 | + runs-on: ${{ matrix.architecture.runner }} |
| 50 | + permissions: |
| 51 | + packages: write |
| 52 | + steps: |
| 53 | + - name: Checkout repository |
| 54 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 55 | + - name: Set up Docker Buildx |
| 56 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 57 | + - name: Login to GitHub Registry |
| 58 | + if: ${{ github.event_name == 'push' }} |
| 59 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 60 | + with: |
| 61 | + registry: ${{ env.CONTAINER_REGISTRY }} |
| 62 | + username: ${{ github.repository_owner }} |
| 63 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 64 | + - name: Prepare environment |
| 65 | + run: | |
| 66 | + # Convert the repository name to lowercase as the organization name is |
| 67 | + # uppercase, which is not permitted by the Docker registry. It's 2025 and GitHub |
| 68 | + # still does not provide convenient action expression syntax for lowercase. |
| 69 | + GITHUB_REPO=${{ github.repository }} |
| 70 | + CONTAINER_REPO=${GITHUB_REPO@L} |
| 71 | + echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV |
| 72 | + echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV |
| 73 | + PLATFORM=${{ matrix.architecture.platform }} |
| 74 | + echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV |
| 75 | + - name: Prepare container metadata |
| 76 | + id: meta |
| 77 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 78 | + env: |
| 79 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor |
| 80 | + with: |
| 81 | + images: ${{ env.CONTAINER_IMAGE }} |
| 82 | + tags: | |
| 83 | + type=raw,value=ubi |
| 84 | + type=sha,prefix=ubi-sha- |
| 85 | + labels: | |
| 86 | + org.opencontainers.image.authors=For inquiries, please use https://${{ github.repository }}/issues |
| 87 | + org.opencontainers.image.documentation=https://${{ github.repository }} |
| 88 | + org.opencontainers.image.vendor=XRPLF |
| 89 | + org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }} |
| 90 | + - name: Build and push the Docker image |
| 91 | + id: build |
| 92 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 93 | + with: |
| 94 | + build-args: | |
| 95 | + BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom |
| 96 | + BUILDKIT_INLINE_CACHE=1 |
| 97 | + RHEL_ARCH=${{ matrix.architecture.name }} |
| 98 | + RHEL_VERSION=${{ matrix.os.release }} |
| 99 | + context: . |
| 100 | + file: docker/rhel-ubi/Dockerfile |
| 101 | + outputs: type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ env.PUSH }} |
| 102 | + platforms: ${{ matrix.architecture.platform }} |
| 103 | + provenance: mode=max |
| 104 | + push: ${{ env.PUSH }} |
| 105 | + sbom: true |
| 106 | + secrets: | |
| 107 | + "RHEL_KEY=${{ secrets.RHEL_KEY }}" |
| 108 | + "RHEL_ORG=${{ secrets.RHEL_ORG }}" |
| 109 | + labels: ${{ steps.meta.outputs.labels }} |
| 110 | + - name: Export digest |
| 111 | + if: ${{ env.PUSH }} |
| 112 | + run: | |
| 113 | + mkdir -p /tmp/digests |
| 114 | + DIGEST="${{ steps.build.outputs.digest }}" |
| 115 | + touch "/tmp/digests/${DIGEST#sha256:}" |
| 116 | + - name: Upload digest |
| 117 | + if: ${{ env.PUSH }} |
| 118 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 119 | + with: |
| 120 | + name: digests-${{ matrix.os.release }}-${{ env.PLATFORM_PAIR }} |
| 121 | + path: /tmp/digests/* |
| 122 | + if-no-files-found: error |
| 123 | + retention-days: 1 |
| 124 | + |
| 125 | + merge: |
| 126 | + if: ${{ github.event_name == 'push' }} |
| 127 | + strategy: |
| 128 | + matrix: |
| 129 | + os: |
| 130 | + - release: 8 |
| 131 | + - release: 9 |
| 132 | + - release: 10 |
| 133 | + runs-on: ubuntu-24.04 |
| 134 | + needs: |
| 135 | + - build |
| 136 | + permissions: |
| 137 | + packages: write |
| 138 | + steps: |
| 139 | + - name: Checkout repository |
| 140 | + uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0 |
| 141 | + - name: Download digests |
| 142 | + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 |
| 143 | + with: |
| 144 | + path: /tmp/digests |
| 145 | + pattern: digests-${{ matrix.os.release }}-* |
| 146 | + merge-multiple: true |
| 147 | + - name: Set up Docker Buildx |
| 148 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 149 | + - name: Login to GitHub Registry |
| 150 | + if: ${{ github.event_name == 'push' }} |
| 151 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 152 | + with: |
| 153 | + registry: ${{ env.CONTAINER_REGISTRY }} |
| 154 | + username: ${{ github.repository_owner }} |
| 155 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + - name: Prepare environment |
| 157 | + run: | |
| 158 | + GITHUB_REPO=${{ github.repository }} |
| 159 | + CONTAINER_REPO=${GITHUB_REPO@L} |
| 160 | + echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/rhel-${{ matrix.os.release }}" >> $GITHUB_ENV |
| 161 | + - name: Prepare container metadata |
| 162 | + id: meta |
| 163 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 164 | + env: |
| 165 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: index |
| 166 | + with: |
| 167 | + images: ${{ env.CONTAINER_IMAGE }} |
| 168 | + tags: | |
| 169 | + type=raw,value=ubi |
| 170 | + type=sha,prefix=ubi-sha- |
| 171 | + - name: Create manifest list and push |
| 172 | + working-directory: /tmp/digests |
| 173 | + run: | |
| 174 | + eval "docker buildx imagetools create \ |
| 175 | + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 176 | + $(jq -cr '.annotations | map("--annotation \"" + . + "\"") | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 177 | + $(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)" |
| 178 | + - name: Inspect image |
| 179 | + run: | |
| 180 | + docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments