name: "Build"

permissions:
  contents: read
on:
  workflow_call:
  workflow_dispatch:
  push:
    branches:
      - main
  schedule:
    - cron: "0 14 * * 2" # 2pm Patch Tuesday

concurrency:
  group: ${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  build-container:
    uses: ./.github/workflows/docker.build.yml
    secrets: inherit
    permissions:
      contents: read
      packages: write
  check-php:
    uses: ./.github/workflows/php.check.yml
    secrets: inherit
    permissions:
      contents: read
      checks: write
  check-trunk:
    uses: ./.github/workflows/trunk.check.yml
    secrets: inherit
    permissions:
      contents: read
      checks: write
  release-container:
    needs:
      - build-container
      - check-php
      - check-trunk
    uses: ./.github/workflows/docker.release.yml
    secrets: inherit
    permissions:
      contents: read
      packages: write