delete-artifact 项目使用教程
1. 项目目录结构及介绍
delete-artifact/
├── .github/
│ └── workflows/
│ └── action.yml
├── dist/
├── src/
│ ├── index.ts
│ └── ...
├── .editorconfig
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── action.yml
├── package-lock.json
├── package.json
└── tsconfig.json
目录结构介绍
- .github/workflows/: 包含GitHub Actions的工作流配置文件。
- dist/: 编译后的TypeScript文件存放目录。
- src/: 源代码目录,包含TypeScript文件。
- .editorconfig: 编辑器配置文件,用于统一代码风格。
- .gitignore: Git忽略文件配置。
- CHANGELOG.md: 项目更新日志。
- LICENSE: 项目许可证文件。
- README.md: 项目介绍和使用说明。
- action.yml: GitHub Action的配置文件。
- package-lock.json: 锁定npm包版本。
- package.json: 项目依赖和脚本配置。
- tsconfig.json: TypeScript配置文件。
2. 项目启动文件介绍
项目的启动文件位于src/index.ts
。这个文件是TypeScript代码的入口点,负责处理删除GitHub Actions工作流中的artifacts。
// src/index.ts
import { deleteArtifact } from './deleteArtifact';
// 启动逻辑
deleteArtifact();
3. 项目的配置文件介绍
action.yml
action.yml
是GitHub Action的配置文件,定义了Action的输入、输出和运行环境。
name: 'Delete Artifact'
description: 'A GitHub Action to delete artifacts within the workflow run'
inputs:
name:
description: 'Name of the artifact to delete'
required: true
failOnError:
description: 'Whether to fail the action if an artifact cannot be deleted'
required: false
default: true
runs:
using: 'node16'
main: 'dist/index.js'
package.json
package.json
是npm包的配置文件,定义了项目的依赖、脚本和元数据。
{
"name": "delete-artifact",
"version": "1.0.0",
"description": "A GitHub Action to delete artifacts within the workflow run",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"test": "jest"
},
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.20",
"jest": "^26.6.3",
"typescript": "^4.1.3"
}
}
tsconfig.json
tsconfig.json
是TypeScript的配置文件,定义了TypeScript编译器的选项。
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist"
},
"include": ["src/**/*"]
}
通过以上配置文件和目录结构,您可以更好地理解和使用delete-artifact
项目。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考