name: Handle Email Issues

on:
  issues:
    types: [opened]

jobs:
  handle_email_issues:
    if: startsWith(github.event.issue.title, '[邮箱订阅]')
    runs-on: ubuntu-latest

    steps:
    - name: Add subscribed label
      uses: actions-cool/issues-helper@v3
      with:
        actions: 'add-labels'
        token: ${{ secrets.GITHUB_TOKEN }}
        issue-number: ${{ github.event.issue.number }}
        labels: 'subscribed'

    - name: Comment on issue
      uses: actions-cool/issues-helper@v3
      with:
        actions: 'create-comment'
        token: ${{ secrets.GITHUB_TOKEN }}
        issue-number: ${{ github.event.issue.number }}
        body: |
          🤩你好呀！ ${{ github.event.issue.user.login }}！你已经成功通过邮件订阅了本站啦！若有新文章将通过邮箱推送给你！谢谢你的订阅！
          😥如果您实在想要关闭订阅，在右下角直接删除这个issue就好！咕咕咕咕咕咕咕！感谢你的订阅！

    - name: Close issue
      uses: actions-cool/issues-helper@v3
      with:
        actions: 'close-issue'
        token: ${{ secrets.GITHUB_TOKEN }}
        issue-number: ${{ github.event.issue.number }}
