|
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | + inputs: |
| 4 | + image-prefix: |
| 5 | + description: "gets suffixed with 'base' and 'sdk' to create actual image name" |
| 6 | + default: ghcr.io/viamrobotics/cpp- |
| 7 | + dockerfile: |
| 8 | + default: Dockerfile.debian.bullseye |
| 9 | + tag: |
| 10 | + default: bullseye-amd64 |
| 11 | + build-base: |
| 12 | + description: "whether to build the base image. the base images change less often and may not be necessary to rebuild." |
| 13 | + type: boolean |
| 14 | + default: false |
| 15 | + build-sdk: |
| 16 | + description: "whether to build the SDK image. if this is true and no corresponding base image exists, the job will fail." |
| 17 | + type: boolean |
| 18 | + default: false |
| 19 | + push: |
| 20 | + description: "whether to push the images after building them" |
| 21 | + type: boolean |
| 22 | + default: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + build-container: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + permissions: |
| 28 | + contents: read |
| 29 | + packages: write |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + |
| 33 | + # build base (if inputs.build-base) |
| 34 | + - uses: docker/metadata-action@v5 |
| 35 | + id: base-meta |
| 36 | + if: inputs.build-base |
| 37 | + with: |
| 38 | + images: ${{ inputs.image-prefix }}base |
| 39 | + - uses: docker/build-push-action@v5 |
| 40 | + if: inputs.build-base |
| 41 | + with: |
| 42 | + push: ${{ inputs.push }} |
| 43 | + tags: "${{ inputs.image-prefix }}base:${{ inputs.tag }}" |
| 44 | + file: etc/docker/base-images/${{ inputs.dockerfile }} |
| 45 | + labels: ${{ steps.base-meta.output.labels }} |
| 46 | + |
| 47 | + # build sdk (if inputs.build-sdk) |
| 48 | + - uses: docker/metadata-action@v5 |
| 49 | + id: sdk-meta |
| 50 | + if: inputs.build-sdk |
| 51 | + with: |
| 52 | + images: ${{ inputs.image-prefix }}sdk |
| 53 | + - uses: docker/build-push-action@v5 |
| 54 | + if: inputs.build-sdk |
| 55 | + with: |
| 56 | + build-args: | |
| 57 | + BASE_TAG=${{ inputs.image-prefix }}base:${{ inputs.tag }} |
| 58 | + push: ${{ inputs.push }} |
| 59 | + tags: "${{ inputs.image-prefix }}sdk:${{ inputs.tag }}" |
| 60 | + file: etc/docker/Dockerfile.sdk-build |
| 61 | + labels: ${{ steps.sdk-meta.output.labels }} |
0 commit comments