name: Build and Publish Application Image on: workflow_call: inputs: name: required: true type: string description: "The name of the application to build." dockerfile: required: false type: string default: "Dockerfile" description: "The Dockerfile to use for building the image." flavor: required: false type: string default: "" description: "The flavor of the image to build." platforms: required: false type: string default: "linux/amd64" description: "The platforms to build for." env: FLAVOR_PREFIX: ${{ inputs.flavor && format('{0}-', inputs.flavor) || '' }} jobs: build-app: name: Build and Publish Application Image runs-on: ubuntu-latest permissions: packages: write contents: read steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract metadata (tags, labels) for Docker uses: docker/metadata-action@v5 id: meta with: images: ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}${{ inputs.name }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} type=sha,format=long - name: Log in to the Container registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v6 with: context: apps/${{ inputs.name }} file: apps/${{ inputs.name }}/${ inputs.dockerfile || 'Dockerfile' }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} build-args: | BASE_IMAGE=ghcr.io/${{ github.repository }}/${{ env.FLAVOR_PREFIX }}base:sha-${{ github.sha }} platforms: ${{ inputs.platforms || 'linux/amd64' }}