name: Reusable Image Builder on: workflow_call: inputs: dockerfile: required: true type: string build-json: required: true type: string build-args: required: false default: "" type: string build-platforms: required: false default: linux/amd64,linux/arm64,linux/arm/v7 type: string concurrency: group: ${{ github.workflow }}-${{ fromJSON(inputs.build-json).name }}-${{ fromJSON(inputs.build-json).version }} cancel-in-progress: false jobs: build-image: name: Build ${{ fromJSON(inputs.build-json).name }} @ ${{ fromJSON(inputs.build-json).version }} runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v3 - name: Login to Github Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Build ${{ fromJSON(inputs.build-json).name }} uses: docker/build-push-action@v4 with: context: . file: ${{ inputs.dockerfile }} tags: ${{ fromJSON(inputs.build-json).image_tag }} platforms: ${{ inputs.build-platforms }} build-args: ${{ inputs.build-args }} push: true cache-from: type=registry,ref=${{ fromJSON(inputs.build-json).cache_tag }} cache-to: type=registry,mode=max,ref=${{ fromJSON(inputs.build-json).cache_tag }}