name: Pre-release

on:
  release:
    types: [created]

jobs:
  check-docs-update:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: true
      matrix:
        php: [7.4, 8.1, 8.2]
        
    steps:
      - uses: actions/checkout@v2
      - uses: technote-space/get-diff-action@v6
        with:
          PATTERNS: |
            +(documentation)/*.md
            *.md
            CHANGE*.md
          FILES: |
            CHANGELOG.md

      - name: log git diff
        run: |
          echo ${{ env.GIT_DIFF }}
          echo ${{ env.MATCHED_FILES }}
          echo ${{ env.GIT_DIFF_FILTERED }}

      - name: Check if README.md or Doc/** is updated else exit
        if: (env.GIT_DIFF == '')
        run: |
          echo Update documentation files and README.md before push
          exit 1

      - name: push build status to Slack
        uses: 8398a7/action-slack@v3
        with:
          status: ${{ job.status }}
          fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        if: always()
