name: Documentation

on:
  push:
    branches:
      - main

jobs:

  changes:
    runs-on: ubuntu-latest
    if: |
      (github.repository == 'kubernetes/ingress-nginx')
    outputs:
      docs: ${{ steps.filter.outputs.docs }}
      charts: ${{ steps.filter.outputs.charts }}

    steps:

      - name: Checkout
        uses: actions/checkout@v2

      - uses: dorny/paths-filter@v2
        id: filter
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          filters: |
            docs:
              - 'docs/**/*'

  docs:
    name: Update
    runs-on: ubuntu-latest
    needs:
      - changes
    if: |
      (github.repository == 'kubernetes/ingress-nginx') &&
      (needs.changes.outputs.docs == 'true')

    steps:

      - name: Checkout master
        uses: actions/checkout@v2

      - name: Deploy
        uses: ./.github/actions/mkdocs
        env:
          PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
