name: Check Issue for Keywords on: issues: types: [opened] # Triggers when an issue is opened jobs: check_keywords: runs-on: ubuntu-latest # You can use any runner; Ubuntu is the most common steps: - name: Checkout repository uses: actions/checkout@v3 - name: Check for keywords in issue title and body id: check_keywords run: | # Define the list of keywords keywords=("Virus" "Malware" "Windows Defender" "Antivirus") # Get the issue title and body from the event context ISSUE_TITLE="${{ github.event.issue.title }}" ISSUE_BODY="${{ github.event.issue.body }}" # Check if any of the keywords are present in the title or body for keyword in "${keywords[@]}"; do if [[ "$ISSUE_TITLE" == *"$keyword"* ]] || [[ "$ISSUE_BODY" == *"$keyword"* ]]; then echo "Keyword '$keyword' found in the issue" echo "contains_keyword=true" >> $GITHUB_ENV break fi done - name: Comment and close issue if keyword found if: env.contains_keyword == 'true' # Only run if a keyword was found run: | ISSUE_NUMBER="${{ github.event.issue.number }}" # Post a comment on the issue curl -X POST \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -d '{"body": "Bum behavior. Closed"}' \ "https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER/comments" # Close the issue curl -X PATCH \ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ -d '{"state": "closed"}' \ "https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER"