|
| 1 | +name: Build UBI ppc64le Dependency |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - build/dependencies/Dockerfile.ubi-ppc64le |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + nginx_version: |
| 12 | + type: string |
| 13 | + description: "NGINX Version to build for" |
| 14 | + required: false |
| 15 | + force: |
| 16 | + type: boolean |
| 17 | + description: "Force rebuild" |
| 18 | + required: false |
| 19 | + default: false |
| 20 | + |
| 21 | +env: |
| 22 | + IMAGE_NAME: ghcr.io/nginxinc/dependencies/nginx-ubi-ppc64le |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.ref_name }}-ubi-ppc64le-build |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +jobs: |
| 29 | + checks: |
| 30 | + name: Check versions |
| 31 | + runs-on: ubuntu-22.04 |
| 32 | + permissions: |
| 33 | + packages: read |
| 34 | + contents: read |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + outputs: |
| 38 | + nginx_version: ${{ steps.var.outputs.nginx_version }} |
| 39 | + njs_version: ${{ steps.var.outputs.njs_version }} |
| 40 | + target_exists: ${{ steps.var.outputs.target_image_exists }} |
| 41 | + steps: |
| 42 | + - name: Checkout Repository |
| 43 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 44 | + |
| 45 | + - name: Login to GitHub Container Registry |
| 46 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 |
| 47 | + with: |
| 48 | + registry: ghcr.io |
| 49 | + username: ${{ github.repository_owner }} |
| 50 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + |
| 52 | + - name: Output Variables |
| 53 | + id: var |
| 54 | + run: | |
| 55 | + if [ -n "${{ inputs.nginx_version }}" ]; then |
| 56 | + nginx_v=${{ inputs.nginx_version }} |
| 57 | + else |
| 58 | + nginx_v=$(grep -m1 'FROM nginx:' <build/dependencies/Dockerfile.ubi-ppc64le | cut -d '@' -f1 | awk -F'[: ]' '{print $3}') |
| 59 | + fi |
| 60 | + target_image=${{ env.IMAGE_NAME }}:nginx-${nginx_v} |
| 61 | + if docker manifest inspect ${target_image}; then |
| 62 | + target_image_exists=true |
| 63 | + else |
| 64 | + target_image_exists=false |
| 65 | + fi |
| 66 | + docker pull nginx:$nginx_v || exit 1 |
| 67 | + njs=$(docker run nginx:$nginx_v env | grep NJS_VERSION | cut -d= -f2) |
| 68 | + echo "> Outputs -------------------------------" |
| 69 | + echo "NJS_VERSION=$njs" |
| 70 | + echo "nginx_version=${nginx_v}" |
| 71 | + echo "njs_version=${njs}" |
| 72 | + echo "target_image_exists=${target_image_exists}" |
| 73 | + echo "nginx_version=${nginx_v}" >> $GITHUB_OUTPUT |
| 74 | + echo "njs_version=${njs}" >> $GITHUB_OUTPUT |
| 75 | + echo "target_image_exists=${target_image_exists}" >> $GITHUB_OUTPUT |
| 76 | +
|
| 77 | + build-binaries: |
| 78 | + name: Build Binary Container Image |
| 79 | + if: ${{ needs.checks.outputs.target_exists != 'true' || inputs.force }} |
| 80 | + needs: checks |
| 81 | + runs-on: ubuntu-22.04 |
| 82 | + permissions: |
| 83 | + packages: write |
| 84 | + contents: read |
| 85 | + strategy: |
| 86 | + fail-fast: false |
| 87 | + steps: |
| 88 | + - name: Checkout Repository |
| 89 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 90 | + |
| 91 | + - name: Setup QEMU |
| 92 | + uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee # v3.1.0 |
| 93 | + with: |
| 94 | + platforms: arm64,ppc64le,s390x |
| 95 | + |
| 96 | + - name: Docker Buildx |
| 97 | + uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 |
| 98 | + |
| 99 | + - name: Login to GitHub Container Registry |
| 100 | + uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3.2.0 |
| 101 | + with: |
| 102 | + registry: ghcr.io |
| 103 | + username: ${{ github.repository_owner }} |
| 104 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 105 | + |
| 106 | + - name: Docker meta |
| 107 | + id: meta |
| 108 | + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1 |
| 109 | + with: |
| 110 | + images: | |
| 111 | + name=${{ env.IMAGE_NAME }},enable=true |
| 112 | + tags: | |
| 113 | + type=raw,value=nginx-${{ needs.checks.outputs.nginx_version }},enable=true |
| 114 | + env: |
| 115 | + DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index |
| 116 | + |
| 117 | + - name: Build and push |
| 118 | + uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0 |
| 119 | + with: |
| 120 | + file: ./build/dependencies/Dockerfile.ubi-ppc64le |
| 121 | + context: "." |
| 122 | + pull: true |
| 123 | + push: true |
| 124 | + # build multi-arch so that it can be mounted from any image |
| 125 | + # even though only ppc64le will contain binaries |
| 126 | + platforms: "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x" |
| 127 | + tags: ${{ steps.meta.outputs.tags }} |
| 128 | + labels: ${{ steps.meta.outputs.labels }} |
| 129 | + annotations: ${{ steps.meta.outputs.annotations }} |
| 130 | + cache-from: type=gha,scope=nginx-ubi-ppc64le |
| 131 | + cache-to: type=gha,scope=nginx-ubi-ppc64le,mode=max |
| 132 | + target: final |
| 133 | + sbom: false |
| 134 | + provenance: mode=max |
| 135 | + build-args: | |
| 136 | + NGINX=${{ needs.checks.outputs.nginx_version }} |
| 137 | + NJS=${{ needs.checks.outputs.njs_version }} |
0 commit comments