Google Cloud SDK 安装与配置 GitHub Action 教程

Google Cloud SDK 安装与配置 GitHub Action 教程

setup-gcloud A GitHub Action for installing and configuring the gcloud CLI. setup-gcloud 项目地址: https://gitcode.com/gh_mirrors/se/setup-gcloud

1. 项目目录结构及介绍

.
├── dist/
├── src/
├── tests/
├── .gitignore
├── .prettierrc.js
├── CHANGELOG.md
├── CODEOWNERS
├── LICENSE
├── README.md
├── action.yml
├── eslint.config.mjs
├── package-lock.json
├── package.json
└── tsconfig.json

目录结构介绍

  • dist/: 存放编译后的文件。
  • src/: 存放源代码文件。
  • tests/: 存放测试文件。
  • .gitignore: Git 忽略文件配置。
  • .prettierrc.js: Prettier 代码格式化配置文件。
  • CHANGELOG.md: 项目更新日志。
  • CODEOWNERS: 代码所有者配置文件。
  • LICENSE: 项目许可证文件。
  • README.md: 项目说明文档。
  • action.yml: GitHub Action 配置文件。
  • eslint.config.mjs: ESLint 配置文件。
  • package-lock.json: npm 包锁定文件。
  • package.json: npm 包管理文件。
  • tsconfig.json: TypeScript 配置文件。

2. 项目的启动文件介绍

项目的启动文件是 action.yml,这是一个 GitHub Action 的配置文件。它定义了 Action 的输入、输出、运行环境等信息。

action.yml 文件内容

name: 'Setup Google Cloud SDK'
description: 'A GitHub Action for installing and configuring the gcloud CLI'
inputs:
  version:
    description: 'A string representing the version or version constraint of the Cloud SDK (gcloud) to install'
    default: 'latest'
  project_id:
    description: 'ID of the Google Cloud project'
  install_components:
    description: 'List of additional gcloud components to install'
  skip_install:
    description: 'Skip installation of gcloud and use the system-supplied version instead'
outputs:
  version:
    description: 'Version of gcloud that was installed'
runs:
  using: 'node20'
  main: 'dist/index.js'

启动文件介绍

  • name: Action 的名称。
  • description: Action 的描述。
  • inputs: 定义了 Action 的输入参数,如 versionproject_id 等。
  • outputs: 定义了 Action 的输出参数,如 version
  • runs: 定义了 Action 的运行环境及主文件路径。

3. 项目的配置文件介绍

.prettierrc.js

module.exports = {
  semi: true,
  trailingComma: 'all',
  singleQuote: true,
  printWidth: 80,
  tabWidth: 2,
};

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

eslint.config.mjs

export default [
  {
    files: ['**/*.js', '**/*.mjs', '**/*.jsx', '**/*.ts', '**/*.tsx'],
    rules: {
      'no-unused-vars': 'error',
      'no-console': 'warn',
    },
  },
];

配置文件介绍

  • .prettierrc.js: 配置代码格式化工具 Prettier,定义了代码风格规则。
  • tsconfig.json: 配置 TypeScript 编译选项,定义了编译目标、模块系统、严格模式等。
  • eslint.config.mjs: 配置 ESLint,定义了代码检查规则。

通过以上配置文件,项目可以确保代码风格一致、编译正确、代码质量高。

setup-gcloud A GitHub Action for installing and configuring the gcloud CLI. setup-gcloud 项目地址: https://gitcode.com/gh_mirrors/se/setup-gcloud

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邴治盟Walton

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值