Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add toggle-labels action #132

Merged
merged 19 commits into from
Jan 31, 2023

Conversation

Wxh16144
Copy link
Member

@Wxh16144 Wxh16144 commented Jan 12, 2023

🤔 这个变动的性质是?/ What is the nature of this change?

  • 新特性提交 / New feature
  • bug 修复 / Fix bug
  • 样式优化 / Style optimization
  • 代码风格优化 / Code style optimization
  • 性能优化 / Performance optimization
  • 构建优化 / Build optimization
  • 网站、文档、Demo 改进 / Website, documentation, demo improvements
  • 重构代码或样式 / Refactor code or style
  • 测试相关 / Test related
  • 其他 / Other

🔗 相关 Issue / Related Issue

💡 需求背景和解决方案 / Background or solution

需求背景

举个🌰:在维护 issue labels 的时候,会对新建的 issue 添加统一 Unread 标签, 然后对 issue body 进行判断,对不符合条件的 issue 我们期望移除 Unread, 然后追加一个 Invalid label, 现有的 action 不支持 remove-labels,add-labels 同时使用。所以需要一个新的 action。

解决方案

新建一个 toggle-labels action,对现有的 labels 和 action 入参进行判断,如果现有 labels 在 action 入参中存在,则删除这个 label ,反之如果 labels 在 action 入参中不存在,则添加 action 入参的 labels。

Example

假定我们的 action.yml 配置如下:

name: Issues Check

on:
  issues:
    types: [opened]

jobs:
  label_issues:
    runs-on: ubuntu-latest
    permissions:
      issues: write
    steps:
      - name: Add labels
        uses: actions-cool/issues-helper@v3
        with:
          actions: 'add-labels'
          token: ${{ secrets.GITHUB_TOKEN }}
          issue-number: ${{ github.event.issue.number }}
          labels: 'Unread'

      - name: check Invalid label
        uses: actions-cool/issues-helper@v3
        if: contains(github.event.issue.body, 'actions-cool') == false
        with:
          actions: 'toggle-labels,close-issue'
          token: ${{ secrets.GITHUB_TOKEN }}
          issue-number: ${{ github.event.issue.number }}
          labels: 'Unread,Invalid'
      
  • case 1. 创建一个不带 body 的 issue

  • result: 一个打开且带有 Unread 标签的 issue。

  • case 2. 创建一个 body 带 actions-cool 关键词的 issue

  • result: 一个关闭且带有 Invalid 标签的 issue

preview:
image

case:

  • init.issueLabels 表示当前 issue 上的 labels
  • init.actionInput 表示用户 action 配置 labels
  • toggleLabels.removeLabels 实际执行结果需要删除的 labels
  • toggleLabels.addLabels 实际执行结果需要添加的 labels

image

📝 更新日志 / Changelog

Language Changelog
🇺🇸 English add toggle-labels action
🇨🇳 Chinese 添加 toggle-labels 功能

@github-actions
Copy link

github-actions bot commented Jan 12, 2023

😭 Deploy PR Preview failed.

@Wxh16144 Wxh16144 changed the title Wuxh/feat toggle labels feat: add toggle-labels action Jan 12, 2023
@xrkffgg
Copy link
Member

xrkffgg commented Jan 13, 2023

功能描述可以再清晰一下

@Wxh16144
Copy link
Member Author

功能描述可以再清晰一下

pr 描述已更新

@xrkffgg
Copy link
Member

xrkffgg commented Jan 13, 2023

  1. 功能描述可以再清晰一下指对用户的描述,即 readme 和 web 里
  2. 放在进阶里
  3. 功能按照顺序哈

@Wxh16144
Copy link
Member Author

  1. 功能描述可以再清晰一下指对用户的描述,即 readme 和 web 里
  2. 放在进阶里
  3. 功能按照顺序哈

大佬,我已经更新好了,麻烦 review 一下呢?(英文不太好,用的翻译😭

README.zh-CN.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.zh-CN.md Outdated Show resolved Hide resolved
src/helper/base.ts Outdated Show resolved Hide resolved
src/helper/helper.ts Outdated Show resolved Hide resolved
src/issue/issue.ts Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
src/types.ts Outdated Show resolved Hide resolved
@Wxh16144
Copy link
Member Author

抱歉,我遗留了很多东西,希望下次细心点,麻烦作者重新 review 一下

@xrkffgg xrkffgg merged commit 6a55b3a into actions-cool:main Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants