name: Check Issues

on:
  issues:
    types: [opened]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - name: Check out
        uses: actions/checkout@v2
      - name: Read latest version code
        run: |
          ver=$(sed -n 's/^magisk.versionCode=//p' gradle.properties)
          echo MAGISK_VERSION_CODE=$ver >> $GITHUB_ENV
      - if: contains(github.event.issue.body, format('Magisk version code{0} ', ':')) != true
        id: close
        name: Close Issue(template)
        uses: peter-evans/close-issue@v1
        with:
          comment: This issue is being automatically closed because it does not follow the issue template.
      - if: steps.close.conclusion == 'skipped' && contains(github.event.issue.body, format('Magisk version code{0} {1}', ':', env.MAGISK_VERSION_CODE)) != true
        name: Close Issue(latest canary)
        uses: peter-evans/close-issue@v1
        with:
          comment: This issue is being automatically closed because latest canary Magisk version code is ${{ env.MAGISK_VERSION_CODE }}.
