Keepalive Workflow 使用教程

Keepalive Workflow 使用教程

keepalive-workflow GitHub action to prevent GitHub from suspending your cronjob based triggers due to repository inactivity keepalive-workflow 项目地址: https://gitcode.com/gh_mirrors/ke/keepalive-workflow

1. 项目目录结构及介绍

Keepalive Workflow 是一个用于保持 GitHub 仓库活跃状态的 GitHub Action。以下是项目的目录结构及其说明:

.
├── .github/
│   ├── workflows/
│   │   └── keepalive.yml  # GitHub Action 工作流配置文件
├── dist/
├── .all-contributorsrc
├── .editorconfig
├── .gitignore
├── .jshintrc
├── .npmignore
├── .npmrc
├── .nvmrc
├── LICENSE           # 许可证文件
├── README.md         # 项目说明文件
├── action.yml        # GitHub Action 配置文件
├── index.js          # JavaScript 执行文件
├── library.js        # JavaScript 库文件
├── package.json      # 项目依赖配置文件
├── util.js           # 工具库文件
└── yarn.lock         # Yarn 锁文件

2. 项目的启动文件介绍

项目的启动文件是 index.js。该文件包含了 Keepalive Workflow 的主要逻辑。它会根据配置文件中的设置,通过 GitHub API 或创建一个虚拟提交(dummy commit)来保持仓库的活跃状态。

const core = require('@actions/core');
const { KeepAliveWorkflow, APIKeepAliveWorkflow } = require('keepalive-workflow');

// 使用虚拟提交模式
KeepAliveWorkflow(
  githubToken,
  committerUsername,
  committerEmail,
  commitMessage,
  timeElapsed
).then(
  (message) => {
    core.info(message);
    process.exit(0);
  }
).catch(
  (error) => {
    core.error(error);
    process.exit(1);
  }
);

// 使用 GitHub API 模式
APIKeepAliveWorkflow(
  githubToken,
  { timeElapsed }
).then(
  (message) => {
    core.info(message);
    process.exit(0);
  }
).catch(
  (error) => {
    core.error(error);
    process.exit(1);
  }
);

3. 项目的配置文件介绍

项目的配置文件是 action.yml。该文件定义了 GitHub Action 的输入参数和默认值。以下是配置文件的主要内容:

name: 'Keepalive Workflow'

inputs:
  gh_token:
    description: 'GitHub access token with Repo scope'
    required: false
  commit_message:
    description: 'Commit message used while committing to the repo'
    required: false
  committer_username:
    description: 'Username used while committing to the repo'
    default: 'gkr-bot'
  committer_email:
    description: 'Email id used while committing to the repo'
    default: 'gkr@tuta.io'
  time_elapsed:
    description: 'Time elapsed from the previous commit to trigger a new automated commit'
    default: 45

在这个配置文件中,用户可以自定义 GitHub Token、提交信息、提交者用户名、提交者邮箱以及触发自动提交的时间间隔。这些参数可以在使用 Action 时通过 with 关键字进行覆盖。

keepalive-workflow GitHub action to prevent GitHub from suspending your cronjob based triggers due to repository inactivity keepalive-workflow 项目地址: https://gitcode.com/gh_mirrors/ke/keepalive-workflow

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

苗伊姬Desmond

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

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

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

打赏作者

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

抵扣说明:

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

余额充值