name: "Pull Request: Validate"

on:
  pull_request:
    branches:
      - master
    types:
      - opened
      - edited
      - reopened
      - ready_for_review
      - synchronize

concurrency:
  group: ${{ github.head_ref }}-pr-validate
  cancel-in-progress: true

jobs:
  pr-metadata:
    uses: k8s-at-home/charts/.github/workflows/pr-metadata.yaml@master

  pre-commit-check:
    uses: k8s-at-home/charts/.github/workflows/pre-commit-check.yaml@master
    needs:
      - pr-metadata
    with:
      modifiedFiles: ${{ needs.pr-metadata.outputs.addedOrModifiedFiles }}

  charts-changelog:
    uses: k8s-at-home/charts/.github/workflows/charts-changelog.yaml@master
    needs:
      - pr-metadata
      - pre-commit-check
    with:
      isRenovatePR: ${{ needs.pr-metadata.outputs.isRenovatePR }}
      modifiedCharts: ${{ needs.pr-metadata.outputs.addedOrModifiedCharts }}

  charts-lint:
    uses: k8s-at-home/charts/.github/workflows/charts-lint.yaml@master
    needs:
      - pr-metadata
      - charts-changelog
    with:
      checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }}
      chartChangesDetected: ${{ needs.pr-metadata.outputs.addedOrModified }}

  charts-test:
    uses: k8s-at-home/charts/.github/workflows/charts-test.yaml@master
    needs:
      - pr-metadata
      - charts-changelog
    with:
      checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }}
      chartChangesDetected: ${{ needs.pr-metadata.outputs.addedOrModified }}
