|
| 1 | +name: "yscope-image-build" |
| 2 | + |
| 3 | +inputs: |
| 4 | + dockerfile_path: |
| 5 | + description: "Dockerfile relative path from the root of the project" |
| 6 | + required: true |
| 7 | + image_name_prefix: |
| 8 | + description: "Container image name prefix" |
| 9 | + required: true |
| 10 | + image_registry: |
| 11 | + default: "ghcr.io" |
| 12 | + description: "Container image registry" |
| 13 | + required: false |
| 14 | + image_registry_username: |
| 15 | + default: "${{github.actor}}" |
| 16 | + description: "Container image registry username" |
| 17 | + required: false |
| 18 | + image_registry_password: |
| 19 | + default: "" |
| 20 | + description: "Container image registry password" |
| 21 | + required: false |
| 22 | + platform_id: |
| 23 | + description: "Platform ID of the container (e.g. ubuntu)" |
| 24 | + required: true |
| 25 | + platform_version_id: |
| 26 | + description: "Platform VERSION_ID / VERSION_CODENAME of the container |
| 27 | + (e.g. jammy, focal, etc.)" |
| 28 | + required: true |
| 29 | + |
| 30 | +runs: |
| 31 | + using: "composite" |
| 32 | + steps: |
| 33 | + - name: "Set up Docker Buildx" |
| 34 | + uses: "docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2" |
| 35 | + |
| 36 | + - name: "Login to Image Registry" |
| 37 | + uses: "docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772" |
| 38 | + with: |
| 39 | + registry: "${{inputs.image_registry}}" |
| 40 | + username: "${{inputs.image_registry_username}}" |
| 41 | + password: "${{inputs.image_registry_password}}" |
| 42 | + |
| 43 | + - name: "Sanitize Repository Name" |
| 44 | + id: "sanitization" |
| 45 | + shell: "bash" |
| 46 | + run: | |
| 47 | + # Docker doesn't support repository names with uppercase characters, so we convert the |
| 48 | + # name to lowercase here. |
| 49 | + echo "REPOSITORY=$(echo '${{github.repository}}' | tr '[:upper:]' '[:lower:]')" \ |
| 50 | + >> "$GITHUB_OUTPUT" |
| 51 | +
|
| 52 | + - name: "Update Metadata" |
| 53 | + id: "meta" |
| 54 | + uses: "docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804" |
| 55 | + with: |
| 56 | + images: "${{inputs.image_registry}}/${{steps.sanitization.outputs.REPOSITORY}}\ |
| 57 | + /${{inputs.image_name_prefix}}-x86-${{inputs.platform_id}}-${{inputs.platform_version_id}}" |
| 58 | + |
| 59 | + - name: "Build and Push" |
| 60 | + uses: "docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4" |
| 61 | + with: |
| 62 | + context: "./" |
| 63 | + file: ${{dockerfile_path}} |
| 64 | + push: true |
| 65 | + tags: "${{steps.meta.outputs.tags}}" |
| 66 | + labels: "${{steps.meta.outputs.labels}}" |
0 commit comments