name: Pr Checker

on:
  pull_request:
    types: [edited, synchronize, opened, reopened]

permissions:
  contents: read
  pull-requests: write

jobs:
  pr-open-check:
    permissions:
      issues: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
          cache: 'npm'

      - name: Install packages
        run: |
          npm install

      - name: Code Format Nestjs
        id: codeFormatNest
        run: |
          npm run format:check


      - name: Add Code Format Fail Comment Nest Only
        if: always() && steps.codeFormatNest.outcome == 'failure'
        uses: thollander/actions-comment-pull-request@v1
        with:
          message: |
            Thanks for your contribution ! But your PR does not seem to fit our code format standards. Please run the `npm run format` command and commit the changes.