ybiquitous/npm-audit-fix-action
GitHub: ybiquitous/npm-audit-fix-action
一个 GitHub Action,自动运行「npm audit fix」并生成修复拉取请求,实现依赖安全治理的自动化。
Stars: 7 | Forks: 6
[](https://github.com/ybiquitous/npm-audit-fix-action/actions/workflows/test.yml)
[](https://codecov.io/gh/ybiquitous/npm-audit-fix-action)
# `npm audit fix` 操作
此操作运行 [`npm audit fix`](https://docs.npmjs.com/cli/audit) 并创建拉取请求。
## 用法
例如,您可以通过创建 [`.github/workflows/npm-audit-fix.yml`](.github/workflows/npm-audit-fix.yml) 来添加此操作:
```
name: npm audit fix
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
npm-audit-fix:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: ybiquitous/npm-audit-fix-action@v7
```
### 输入
| 名称 | 说明 | 默认值 |
| ---------------- | ------------------------------------- | --------------------------------------------------------------------- |
| `github_token` | GitHub 令牌。 | `${{ github.token }}` |
| `github_user` | 提交更改的 GitHub 用户名。 | `${{ github.actor }}` |
| `github_email` | 提交更改的 GitHub 用户邮箱。 | `${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com` |
| `branch` | 创建的分支。 | `npm-audit-fix-action/fix` |
| `default_branch` | 默认分支。 | 自动检测。 |
| `commit_title` | 提交消息和拉取请求标题。 | `build(deps): npm audit fix` |
| `labels` | 拉取请求的标签(逗号分隔)。 | `dependencies, javascript, security` |
| `assignees` | 拉取请求的指派人(逗号分隔)。 | n/a |
| `npm_args` | `npm` 命令的参数。 | n/a |
| `path` | 项目根目录路径。 | `.` |
请参阅 [`action.yml`](action.yml)。
### 输出
| 名称 | 说明 |
| ------------------ | ------------------------ |
| `pull_request_url` | 创建的拉取请求的 URL。 |
| `branch_name` | 创建的分支名称。 |
请参阅 [`action.yml`](action.yml)。
### 使用个人访问令牌
如果您希望在由本操作创建的拉取请求上运行 CI,可能需要使用您的 [个人访问令牌](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) 代替 GitHub 的默认令牌:
例如:
```
with:
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
```
原因是默认令牌没有足够的权限来触发 CI。
请参阅有关令牌权限的 [GitHub 文档](https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token)。
## 截图

## 许可证
[MIT](LICENSE) © Masafumi Koba
标签:CMS安全, DevSecOps, GitHub Action, GNU通用公共许可证, JavaScript, MITM代理, Node.js, npm audit, 上游代理, 代码提交, 依赖修复, 依赖管理, 前端安全, 定时任务, 开源框架, 拉取请求, 持续集成, 数据可视化, 暗色界面, 权限控制, 漏洞修复, 结构化查询, 网络安全培训, 自动化PR, 自动化安全, 自定义脚本, 计划任务