|
| 1 | +name: 'Parent Images: Build' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +# Special permissions required for OIDC authentication |
| 7 | +permissions: |
| 8 | + id-token: write |
| 9 | + contents: read |
| 10 | + actions: read |
| 11 | + |
| 12 | +env: |
| 13 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + pi-matrix: |
| 17 | + uses: code-kern-ai/cicd-deployment-scripts/.github/workflows/pi_matrix.yml@parent-images |
| 18 | + secrets: inherit |
| 19 | + with: |
| 20 | + repository: "${{ github.repository_owner }}/refinery-submodule-parent-images" |
| 21 | + |
| 22 | + pi-build: |
| 23 | + name: 'Parent Images: Docker Build' |
| 24 | + runs-on: ubuntu-latest |
| 25 | + needs: [pi-matrix] |
| 26 | + environment: dev |
| 27 | + env: |
| 28 | + PYTHON_VERSION: ${{ vars.PYTHON_VERSION }} |
| 29 | + DEV_CONTAINER_REGISTRY: ${{ vars.DEV_CONTAINER_REGISTRY }} |
| 30 | + DEV_LOGIN_USERNAME: ${{ secrets.DEV_LOGIN_USERNAME }} |
| 31 | + DEV_LOGIN_PASSWORD: ${{ secrets.DEV_LOGIN_PASSWORD }} |
| 32 | + IMAGE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.event.pull_request.head.ref }} |
| 33 | + strategy: |
| 34 | + matrix: |
| 35 | + parent_image_type: ${{ fromJson(needs.pi-matrix.outputs.parent_image_type) }} |
| 36 | + steps: |
| 37 | + - name: Checkout repository |
| 38 | + uses: actions/checkout@v4 |
| 39 | + with: |
| 40 | + token: ${{ secrets.GH_TOKEN }} |
| 41 | + repository: '${{ github.repository_owner }}/refinery-${{ matrix.parent_image_type }}-parent-image' |
| 42 | + fetch-depth: 0 |
| 43 | + submodules: 'true' |
| 44 | + |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@v5 |
| 47 | + with: |
| 48 | + python-version: ${{ env.PYTHON_VERSION }} |
| 49 | + |
| 50 | + - name: Install Dependencies |
| 51 | + run: python -m pip install pip-tools |
| 52 | + |
| 53 | + - name: Compile Requirements |
| 54 | + run: | |
| 55 | + cd ${{ github.workspace }}/submodules/parent-images |
| 56 | + git checkout ${{ github.event.pull_request.head.ref }} |
| 57 | + pip-compile requirements/${{ matrix.parent_image_type }}-requirements.in |
| 58 | +
|
| 59 | + - name: Set up Docker Buildx |
| 60 | + uses: docker/setup-buildx-action@v3 |
| 61 | + with: |
| 62 | + platforms: linux/amd64,linux/arm64 |
| 63 | + |
| 64 | + - name: Set up QEMU |
| 65 | + uses: docker/setup-qemu-action@v3 |
| 66 | + with: |
| 67 | + platforms: arm64,arm |
| 68 | + |
| 69 | + - name: Log into DEV registry |
| 70 | + uses: docker/login-action@v3 |
| 71 | + with: |
| 72 | + registry: "${{ env.DEV_CONTAINER_REGISTRY }}" |
| 73 | + username: "${{ env.DEV_LOGIN_USERNAME }}" |
| 74 | + password: "${{ env.DEV_LOGIN_PASSWORD }}" |
| 75 | + |
| 76 | + - name: Build & Push refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }} |
| 77 | + uses: docker/build-push-action@v5 |
| 78 | + with: |
| 79 | + context: . |
| 80 | + cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-cache |
| 81 | + cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-cache,mode=max,image-manifest=true |
| 82 | + platforms: linux/amd64 |
| 83 | + file: Dockerfile |
| 84 | + tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }} |
| 85 | + push: true |
| 86 | + build-args: | |
| 87 | + platform=linux/amd64 |
| 88 | + label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile |
| 89 | +
|
| 90 | + - name: Build & Push refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-arm64 |
| 91 | + uses: docker/build-push-action@v5 |
| 92 | + with: |
| 93 | + context: . |
| 94 | + cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-arm64-cache |
| 95 | + cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-arm64-cache,mode=max,image-manifest=true |
| 96 | + platforms: linux/arm64 |
| 97 | + file: Dockerfile |
| 98 | + tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.event.pull_request.head.ref }}-${{ matrix.parent_image_type }}-arm64 |
| 99 | + push: true |
| 100 | + build-args: | |
| 101 | + platform=linux/arm64 |
| 102 | + label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile |
| 103 | +
|
| 104 | + - name: Build & Push refinery-parent-images:sha-${{ matrix.parent_image_type }} |
| 105 | + uses: docker/build-push-action@v5 |
| 106 | + with: |
| 107 | + context: . |
| 108 | + cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }}-cache |
| 109 | + cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }}-cache,mode=max,image-manifest=true |
| 110 | + platforms: linux/amd64 |
| 111 | + file: Dockerfile |
| 112 | + tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }} |
| 113 | + push: true |
| 114 | + build-args: | |
| 115 | + platform=linux/amd64 |
| 116 | + label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile |
| 117 | +
|
| 118 | + - name: Build & Push refinery-parent-images:sha-${{ matrix.parent_image_type }}-arm64 |
| 119 | + uses: docker/build-push-action@v5 |
| 120 | + with: |
| 121 | + context: . |
| 122 | + cache-from: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }}-arm64-cache |
| 123 | + cache-to: type=registry,ref=${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }}-arm64-cache,mode=max,image-manifest=true |
| 124 | + platforms: linux/arm64 |
| 125 | + file: Dockerfile |
| 126 | + tags: ${{ env.DEV_CONTAINER_REGISTRY }}/refinery-parent-images:${{ github.sha }}-${{ matrix.parent_image_type }}-arm64 |
| 127 | + push: true |
| 128 | + build-args: | |
| 129 | + platform=linux/arm64 |
| 130 | + label=dockerfile-path=https://github.com/refinery-${{ matrix.parent_image_type }}-parent-image/blob/${{ github.sha }}/Dockerfile |
0 commit comments