|
| 1 | +# Copyright 2024 NVIDIA CORPORATION |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Run this workflow on pull requests |
| 16 | +name: image |
| 17 | + |
| 18 | +on: |
| 19 | + push: |
| 20 | + branches: |
| 21 | + - main |
| 22 | + - release-* |
| 23 | + |
| 24 | +jobs: |
| 25 | + packages: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + package: |
| 30 | + - ubuntu18.04-arm64 |
| 31 | + - ubuntu18.04-amd64 |
| 32 | + - ubuntu18.04-ppc64le |
| 33 | + - centos7-aarch64 |
| 34 | + - centos7-x86_64 |
| 35 | + - centos8-ppc64le |
| 36 | + fail-fast: false |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v4 |
| 39 | + name: Check out code |
| 40 | + - name: Set up QEMU |
| 41 | + uses: docker/setup-qemu-action@v3 |
| 42 | + - name: Set up Docker Buildx |
| 43 | + uses: docker/setup-buildx-action@v3 |
| 44 | + - name: build ${{ matrix.package }} packages |
| 45 | + run: | |
| 46 | + sudo apt-get install -y coreutils build-essential sed git bash make |
| 47 | + echo "Building packages" |
| 48 | + ./scripts/build-packages.sh ${{ matrix.package }} |
| 49 | + - name: 'Upload Artifacts' |
| 50 | + uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + compression-level: 0 |
| 53 | + name: toolkit-container-${{ matrix.package }}-${{ github.run_id }} |
| 54 | + path: ${{ github.workspace }}/dist/* |
| 55 | + |
| 56 | + image: |
| 57 | + runs-on: ubuntu-latest |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + image: [ubuntu20.04, centos7, ubi8, packaging] |
| 61 | + needs: packages |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v4 |
| 64 | + name: Check out code |
| 65 | + - name: Calculate build vars |
| 66 | + id: vars |
| 67 | + run: | |
| 68 | + echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV |
| 69 | + echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV |
| 70 | + REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}" |
| 71 | + echo "${REPO_FULL_NAME}" |
| 72 | + echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV |
| 73 | + |
| 74 | + GENERATE_ARTIFACTS="false" |
| 75 | + if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then |
| 76 | + GENERATE_ARTIFACTS="false" |
| 77 | + elif [[ "${{ github.event_name }}" == "pull_request" && "${{ github.event.pull_request.head.repo.full_name }}" == "${{ github.repository }}" ]]; then |
| 78 | + GENERATE_ARTIFACTS="true" |
| 79 | + elif [[ "${{ github.event_name }}" == "push" ]]; then |
| 80 | + GENERATE_ARTIFACTS="true" |
| 81 | + fi |
| 82 | + echo "PUSH_ON_BUILD=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV |
| 83 | + echo "BUILD_MULTI_ARCH_IMAGES=${GENERATE_ARTIFACTS}" >> $GITHUB_ENV |
| 84 | +
|
| 85 | + - name: Set up QEMU |
| 86 | + uses: docker/setup-qemu-action@v3 |
| 87 | + - name: Set up Docker Buildx |
| 88 | + uses: docker/setup-buildx-action@v3 |
| 89 | + - name: Get built packages |
| 90 | + uses: actions/download-artifact@v4 |
| 91 | + with: |
| 92 | + path: ${{ github.workspace }}/dist/ |
| 93 | + pattern: toolkit-container-* |
| 94 | + merge-multiple: true |
| 95 | + |
| 96 | + - name: Login to GitHub Container Registry |
| 97 | + uses: docker/login-action@v3 |
| 98 | + with: |
| 99 | + registry: ghcr.io |
| 100 | + username: ${{ github.actor }} |
| 101 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + - name: Build image |
| 103 | + env: |
| 104 | + IMAGE_NAME: ghcr.io/${LOWERCASE_REPO_OWNER}/container-toolkit |
| 105 | + VERSION: ${COMMIT_SHORT_SHA} |
| 106 | + run: | |
| 107 | + echo "${VERSION}" |
| 108 | + make -f build/container/Makefile build-${{ matrix.image }} |
0 commit comments