GitHub Slug Action 使用教程
1、项目的目录结构及介绍
GitHub Slug Action 项目的目录结构如下:
.
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── action.yml
├── docs/
├── examples/
├── editorconfig
├── package.json
└── preflight.sh
CODE_OF_CONDUCT.md
: 行为准则文件。CONTRIBUTING.md
: 贡献指南文件。LICENSE
: 项目许可证文件。README.md
: 项目说明文件。SECURITY.md
: 安全指南文件。action.yml
: GitHub Action 的配置文件。docs/
: 文档目录,包含项目的详细文档。examples/
: 示例目录,包含使用该 Action 的示例。editorconfig
: 编辑器配置文件。package.json
: Node.js 项目的配置文件。preflight.sh
: 预检脚本文件。
2、项目的启动文件介绍
GitHub Slug Action 的启动文件是 action.yml
。该文件定义了 Action 的输入、输出和运行步骤。以下是 action.yml
的主要内容:
name: 'GitHub Slug Action'
description: 'GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow'
inputs:
prefix:
description: 'Prefix to add to the slug value'
required: false
default: ''
runs:
using: 'node12'
main: 'dist/index.js'
branding:
icon: 'hash'
color: 'blue'
name
: Action 的名称。description
: Action 的描述。inputs
: 定义了 Action 的输入参数,例如prefix
。runs
: 定义了 Action 的运行方式,使用 Node.js 12 运行dist/index.js
文件。branding
: Action 的品牌信息,包括图标和颜色。
3、项目的配置文件介绍
GitHub Slug Action 的主要配置文件是 action.yml
,如上所述。此外,package.json
文件也包含了项目的配置信息:
{
"name": "github-slug-action",
"version": "4.0.0",
"description": "GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow",
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.js -o dist",
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/rlespinasse/github-slug-action.git"
},
"keywords": [
"github-actions",
"slug",
"short",
"continuous-integration",
"continuous-delivery",
"continuous-deployment",
"workflows"
],
"author": "Romain Lespinasse",
"license": "MIT",
"bugs": {
"url": "https://github.com/rlespinasse/github-slug-action/issues"
},
"homepage": "https://github.com/rlespinasse/github-slug-action#readme",
"dependencies": {
"@actions/core": "^1.2.6"
},
"devDependencies": {
"@vercel/ncc": "^0.24.1",
"jest": "^26.6.3"
}
}
name
: 项目名称。version
: 项目版本。description
: 项目描述。main
: 项目的主入口文件。scripts
: 定义了项目的脚本命令,例如build
和test
。repository
: 项目的仓库信息。keywords
: 项目的关键词。author
: 项目作者。license
: 项目许可证。bugs
: 项目的问题追踪链接。homepage
: 项目的主页链接。dependencies
: 项目的依赖库。