dacbd/create-issue-action
GitHub: dacbd/create-issue-action
一个极简的 GitHub Action,用于在 CI/CD 工作流中通过 REST API 自动创建 GitHub Issue。
Stars: 48 | Forks: 8
# dacbd/create-issue-action@main
GitHub 上排名第一的简单且出色的创建 issue action。🌟
基本上,它是一个转换器,接收你的 yaml 条目,并将其连接到 REST endpoint,从而在 GitHub 上创建 issue。
## 快速开始(或[跳转至高级设置](https://github.com/dacbd/create-issue-action#generate-advanced-report)):
```
steps:
- uses: actions/checkout@v4
- name: create an issue
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
title: Simple test issue
body: my new issue
```
## 配置
### 输入(通过 `with:`)
| 选项 | 默认值 | 说明 |
| ------------ | ------------ | ------------ |
| token | github.token / `required` | 使用 `${{ github.token }}`(等同于 `${{secrets.GITHUB_TOKEN}}`)或创建一个存储在 secrets 存储区中的 PAT。 |
| owner | github.context.repo.owner | 创建 issue 的仓库所有者。从运行 action 的上下文中隐式获取。 |
| repo | github.context.repo.repo | 创建 issue 的目标仓库。从运行 action 的上下文中隐式获取。 |
| title | `required` | |
| body | | |
| milestone | | |
| labels | | 以逗号分隔的标签列表 |
| assignees | | 以逗号分隔的 GitHub 用户名列表,用于指派该 issue |
### 输出
| output | value |
| ------ | ----- |
| json | [查看响应](https://docs.github.com/en/rest/issues/issues#create-an-issue) |
| html_url | issue 的网页 url |
| number | issue 的编号 |
## 用法
### 生成高级报告
```
name: Your Awesome Workflow
...
jobs:
job-that-might-fail:
...
create-issue-if-job-fails:
needs: job-that-might-fail
runs-on: ubuntu-latest
if: always() && needs.job-that-might-fail.result == 'failure'
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Create Issue
uses: dacbd/create-issue-action@main
with:
token: ${{ github.token }}
title: |
[${{ github.workflow }}] failed during [${{ github.event_name }}]
# Auto-assign person who triggered the failure.
assignees: ${{ github.actor }},${{ github.triggering_actor }}
labels: CICD
body: |
## Failure Report:
> [!IMPORTANT]
> Details on failed run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- Author: @${{ github.triggering_actor }}
- Branch: `${{ github.ref }}`
- Commit: ${{ github.sha }}
- Workflow Path: `${{ github.workflow_ref }}`
- [ ] **Task**: Review failed run, fix the issue(s), and re-run until successful.
> This issue was created automatically by GitHub,
> through `dacbd/create-issue-action@main` action
> and KemingHe's contribution.
> **DO NOT** close this issue until resolved.
```
### 使用输出
```
...
steps:
- uses: actions/checkout@v4
- uses: dacbd/create-issue-action@main
id: new-issue
with:
token: ${{ github.token }}
title: Simple test issue
body: my new issue
- run: |
echo "${{ steps.new-issue.outputs.json }}" | jq
echo "${{ steps.new-issue.outputs.json }}" | jq .state
echo "${{ steps.new-issue.outputs.json }}" | jq .labels[].name
```
### 将 issue 转移到私有仓库:
```
name: transpose issue
issues:
types: [labeled]
job:
transpose:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'backend')
steps:
- name: Copy Issue
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.PAT }}
org: octo-org
repo: private-backend-service
title: ${{ github.event.issue.title }}
body: |
Closes: ${{ github.event.issue.html_url }}
# Body
${{ github.event.issue.body }}
```
## Issues 与调试
如果你在使用 `dacbd/create-issue-action@main` 时遇到问题,欢迎创建 issue 或 PR,我们很乐意接受改进或请求。
标签:数据可视化, 自定义脚本