|
| 1 | +name: Build the build-kit |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + runner: |
| 7 | + description: 'Which runner to use' |
| 8 | + required: false |
| 9 | + default: 'ubuntu-24.04' |
| 10 | + type: string |
| 11 | + build_kit_docker_directory: |
| 12 | + description: 'Directory in the repository where the build kit Dockerfile is located' |
| 13 | + required: false |
| 14 | + default: '.ci/build-kit/docker' |
| 15 | + type: string |
| 16 | + base_image_tag_everest_ci: |
| 17 | + description: 'The tag of the everest-ci base image to use for building the build-kit' |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + outputs: |
| 21 | + build_kit_artifact_name: |
| 22 | + description: 'The name of the build-kit artifact' |
| 23 | + value: ${{ jobs.build-build-kit.outputs.build_kit_artifact_name }} |
| 24 | + build_kit_image_tag: |
| 25 | + description: 'The tag of the built build-kit image' |
| 26 | + value: ${{ jobs.build-build-kit.outputs.build_kit_image_tag }} |
| 27 | + |
| 28 | +jobs: |
| 29 | + build-build-kit: |
| 30 | + name: Build the build-kit |
| 31 | + runs-on: ${{ inputs.runner }} |
| 32 | + env: |
| 33 | + BUILD_KIT_ARTIFACT_NAME: build-kit |
| 34 | + BUILD_KIT_IMAGE_NAME: local/build-kit-${{ github.event.repository.name }} |
| 35 | + BUILD_ARGS: | |
| 36 | + BASE_IMAGE_TAG=${{ inputs.base_image_tag_everest_ci }} |
| 37 | + outputs: |
| 38 | + build_kit_image_tag: ${{ steps.set-outputs.outputs.tag }} |
| 39 | + build_kit_artifact_name: ${{ env.BUILD_KIT_ARTIFACT_NAME }} |
| 40 | + steps: |
| 41 | + - name: Checkout Dockerfile |
| 42 | + uses: actions/checkout@v4 |
| 43 | + with: |
| 44 | + repository: ${{ github.repository }} |
| 45 | + path: source |
| 46 | + ref: ${{ github.ref }} |
| 47 | + token: ${{ github.token}} |
| 48 | + fetch-depth: 0 |
| 49 | + - name: Docker Meta |
| 50 | + id: meta |
| 51 | + uses: docker/metadata-action@v5 |
| 52 | + with: |
| 53 | + images: ${{ env.BUILD_KIT_IMAGE_NAME }} |
| 54 | + sep-tags: "," |
| 55 | + - name: Setup Docker buildx |
| 56 | + uses: docker/setup-buildx-action@v3 |
| 57 | + - name: Build |
| 58 | + uses: docker/build-push-action@v6 |
| 59 | + with: |
| 60 | + context: source/${{ inputs.build_kit_docker_directory }} |
| 61 | + push: false |
| 62 | + cache-from: type=gha |
| 63 | + cache-to: type=gha,mode=max |
| 64 | + build-args: ${{ env.BUILD_ARGS }} |
| 65 | + tags: ${{ steps.meta.outputs.tags }} |
| 66 | + labels: ${{ steps.meta.outputs.labels }} |
| 67 | + outputs: type=docker,dest=build-kit.tar |
| 68 | + - name: Upload build-kit image |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: ${{ env.BUILD_KIT_ARTIFACT_NAME }} |
| 72 | + path: build-kit.tar |
| 73 | + - name: Set output tag |
| 74 | + id: set-outputs |
| 75 | + shell: python3 {0} |
| 76 | + run: | |
| 77 | + import os |
| 78 | + tags = "${{ steps.meta.outputs.tags }}".split(",") |
| 79 | + if len(tags) == 0: |
| 80 | + print("No tags found!❌") |
| 81 | + exit(1) |
| 82 | + tag = tags[0] |
| 83 | + with open(os.environ["GITHUB_OUTPUT"], "a") as f: |
| 84 | + f.write(f"tag={tag}\n") |
| 85 | + print(f"Set tag={tag}") |
0 commit comments