<commit_before>---
name: Reusable workflow to build container images

on:
  workflow_call:
    inputs:
      version:
        description: The version of Fluent Bit to create.
        type: string
        required: true
      ref:
        description: The commit, tag or branch of Fluent Bit to checkout for building that creates the version above.
        type: string
        required: true
      registry:
        description: The registry to push container images to.
        type: string
        required: true
      username:
        description: The username for the registry.
        type: string
        required: true
      image:
        description: The name of the container image to push to the registry.
        type: string
        required: true
      environment:
        description: The Github environment to run this workflow on.
        type: string
        required: false
      unstable:
        description: Optionally add metadata to build to indicate an unstable build, set to the contents you want to add.
        type: string
        required: false
        default: ''
    secrets:
      token:
        description: The Github token or similar to authenticate with for the registry.
        required: true
      cosign_private_key:
        description: The optional Cosign key to use for signing the images.
        required: false
      cosign_private_key_password:
        description: If the Cosign key requires a password then specify here, otherwise not required.
        required: false
jobs:
  call-build-images:
    name: Multiarch container images to GHCR
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout code
        if: inputs.ref != '1.8'
        uses: actions/checkout@v3
        with:
          ref: ${{ inputs.ref }}

      - name: Checkout the docker build repo
        if: inputs.ref == '1.8'
        uses: actions/checkout@v3
        with:
          repository: fluent/fluent-bit-docker-image
          ref: '1.8'

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ <PASSWORD> }}

      - name: Extract metadata from Github
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ inputs.registry }}/${{ inputs.image }}
          tags: |
            raw,${{ inputs.version }}
            raw,latest

      - name: Build the production images
        if: inputs.ref != '1.8'
        uses: docker/build-push-action@v2
        with:
          file: ./dockerfiles/Dockerfile
          context: .
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          platforms: linux/amd64, linux/arm64, linux/arm/v7
          target: production
          push: true
          load: false
          build-args: |
            FLB_NIGHTLY_BUILD=${{ inputs.unstable }}

      - id: debug-meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ inputs.registry }}/${{ inputs.image }}
          tags: |
            raw,${{ inputs.version }}-debug
            raw,latest-debug

      - name: Build the debug multi-arch images
        if: inputs.ref != '1.8'
        uses: docker/build-push-action@v2
        with:
          file: ./dockerfiles/Dockerfile
          context: .
          tags: ${{ steps.debug-meta.outputs.tags }}
          labels: ${{ steps.debug-meta.outputs.labels }}
          platforms: linux/amd64, linux/arm64, linux/arm/v7
          target: debug
          push: true
          load: false
          build-args: |
            FLB_NIGHTLY_BUILD=${{ inputs.unstable }}

      - name: Build the legacy image
        if: inputs.ref == '1.8'
        uses: docker/build-push-action@v2
        with:
          file: Dockerfile.x86_64
          context: .
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          platforms: linux/amd64
          push: true
          load: false
          build-args: |
            FLB_TARBALL=https://github.com/fluent/fluent-bit/tarball/${{ inputs.ref }}

  call-build-images-generate-schema:
    if: inputs.ref != '1.8'
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    needs: call-build-images
    permissions:
      contents: read
      packages: read
    steps:
      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ secrets.token }}

      - name: Generate schema
        run: |
          docker run --rm -t ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.version }} -J > fluent-bit-schema.json
          cat fluent-bit-schema.json | jq -M > fluent-bit-schema-pretty.json
        shell: bash

      - name: Upload the schema
        uses: actions/upload-artifact@v2
        with:
          path: ./
          name: fluent-bit-schema*.json
          if-no-files-found: error

  call-build-images-scan:
    name: Trivy + Dockle image scan
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    needs: call-build-images
    permissions:
      contents: read
      packages: read
    steps:
      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ secrets.token }}
<commit_msg>workflows: resolve schema name failure (#5155)<commit_after>---
name: Reusable workflow to build container images

on:
  workflow_call:
    inputs:
      version:
        description: The version of Fluent Bit to create.
        type: string
        required: true
      ref:
        description: The commit, tag or branch of Fluent Bit to checkout for building that creates the version above.
        type: string
        required: true
      registry:
        description: The registry to push container images to.
        type: string
        required: true
      username:
        description: The username for the registry.
        type: string
        required: true
      image:
        description: The name of the container image to push to the registry.
        type: string
        required: true
      environment:
        description: The Github environment to run this workflow on.
        type: string
        required: false
      unstable:
        description: Optionally add metadata to build to indicate an unstable build, set to the contents you want to add.
        type: string
        required: false
        default: ''
    secrets:
      token:
        description: The Github token or similar to authenticate with for the registry.
        required: true
      cosign_private_key:
        description: The optional Cosign key to use for signing the images.
        required: false
      cosign_private_key_password:
        description: If the Cosign key requires a password then specify here, otherwise not required.
        required: false
jobs:
  call-build-images:
    name: Multiarch container images to GHCR
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout code
        if: inputs.ref != '1.8'
        uses: actions/checkout@v3
        with:
          ref: ${{ inputs.ref }}

      - name: Checkout the docker build repo
        if: inputs.ref == '1.8'
        uses: actions/checkout@v3
        with:
          repository: fluent/fluent-bit-docker-image
          ref: '1.8'

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ secrets.token }}

      - name: Extract metadata from Github
        id: meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ inputs.registry }}/${{ inputs.image }}
          tags: |
            raw,${{ inputs.version }}
            raw,latest

      - name: Build the production images
        if: inputs.ref != '1.8'
        uses: docker/build-push-action@v2
        with:
          file: ./dockerfiles/Dockerfile
          context: .
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          platforms: linux/amd64, linux/arm64, linux/arm/v7
          target: production
          push: true
          load: false
          build-args: |
            FLB_NIGHTLY_BUILD=${{ inputs.unstable }}

      - id: debug-meta
        uses: docker/metadata-action@v3
        with:
          images: ${{ inputs.registry }}/${{ inputs.image }}
          tags: |
            raw,${{ inputs.version }}-debug
            raw,latest-debug

      - name: Build the debug multi-arch images
        if: inputs.ref != '1.8'
        uses: docker/build-push-action@v2
        with:
          file: ./dockerfiles/Dockerfile
          context: .
          tags: ${{ steps.debug-meta.outputs.tags }}
          labels: ${{ steps.debug-meta.outputs.labels }}
          platforms: linux/amd64, linux/arm64, linux/arm/v7
          target: debug
          push: true
          load: false
          build-args: |
            FLB_NIGHTLY_BUILD=${{ inputs.unstable }}

      - name: Build the legacy image
        if: inputs.ref == '1.8'
        uses: docker/build-push-action@v2
        with:
          file: Dockerfile.x86_64
          context: .
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          platforms: linux/amd64
          push: true
          load: false
          build-args: |
            FLB_TARBALL=https://github.com/fluent/fluent-bit/tarball/${{ inputs.ref }}

  call-build-images-generate-schema:
    if: inputs.ref != '1.8'
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    needs: call-build-images
    permissions:
      contents: read
      packages: read
    steps:
      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ secrets.<PASSWORD> }}

      - name: Generate schema
        run: |
          docker run --rm -t ${{ inputs.registry }}/${{ inputs.image }}:${{ inputs.version }} -J > fluent-bit-schema.json
          cat fluent-bit-schema.json | jq -M > fluent-bit-schema-pretty.json
        shell: bash

      - name: Upload the schema
        uses: actions/upload-artifact@v2
        with:
          path: ./fluent-bit-schema*.json
          name: fluent-bit-schema-${{ inputs.version }}
          if-no-files-found: error

  call-build-images-scan:
    name: Trivy + Dockle image scan
    runs-on: ubuntu-latest
    environment: ${{ inputs.environment }}
    needs: call-build-images
    permissions:
      contents: read
      packages: read
    steps:
      - name: Log in to the Container registry
        uses: docker/login-action@v1
        with:
          registry: ${{ inputs.registry }}
          username: ${{ inputs.username }}
          password: ${{ <PASSWORD> }}

{'fraction_non_alphanumeric': 0.10167310167310167, 'fraction_numerical': 0.007722007722007722, 'mean_word_length': 1.8195452346395742, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1997288', 'n_tokens_mistral': 3318, 'n_tokens_neox': 3146, 'n_words': 939}