Giter Site home page Giter Site logo

nigui / keepalive-workflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gautamkrishnar/keepalive-workflow

0.0 0.0 0.0 184 KB

GitHub action to prevent GitHub from suspending your cronjob based triggers due to repository inactivity

Home Page: https://github.com/marketplace/actions/keepalive-workflow

License: GNU General Public License v3.0

JavaScript 100.00%

keepalive-workflow's Introduction

Keepalive Workflow npm version

GitHub action to prevent GitHub from suspending your cronjob based triggers due to repository inactivity

Why

GitHub will suspend the scheduled trigger for GitHub action workflows if there is no commit in the repository for the past 60 days. The cron based triggers won't run unless a new commit is made. It shows the message "This scheduled workflow is disabled because there hasn't been activity in this repository for at least 60 days" under the cronjob triggered action.

preview

What

This workflow will automatically create a dummy commit in your repo if the last commit in your repo is 50 days (default) ago. This will keep the cronjob trigger active so that it will run indefinitely without getting suspended by GitHub for inactivity.

How to use

There are two ways you can consume this library in your GitHub actions

Via GitHub Actions (For GitHub Actions users)

You can just include the library as a step after one of your favorite GitHub actions. Your workflow file should have the checkout action defined in one of your steps since this library needs git CLI to work.

name: Github Action with a cronjob trigger
on:
  schedule:
    - cron: "0 0 * * *"

jobs:
  cronjob-based-github-action:
    name: Cronjob based github action
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - # step1
      - # step 2
      - # step n, use it as the last step
      - uses: gautamkrishnar/keepalive-workflow@master # using the workflow with default settings
Let's take an example of [Waka Readme](https://github.com/athul/waka-readme)
name: My awesome readme
on:
  workflow_dispatch:
  schedule:
    # Runs at 12 am UTC
    - cron: "0 0 * * *"

jobs:
  update-readme:
    name: Update this repo's README
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: athul/waka-readme@master
        with:
          WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
      - uses: gautamkrishnar/keepalive-workflow@master # using the workflow with default settings

Via JavaScript library (For GitHub Actions developers)

For developers making awesome GitHub actions, you can consume the library in your javascript-based GitHub action by installing it from NPM. Make sure that your GitHub action uses checkout action since this library needs it as a dependency. You can also ask your users to include it as an additional step as mentioned in the first part.

Install the package

Install via NPM:

npm i keepalive-workflow

Install via Yarn:

yarn add keepalive-workflow

Use it in your own GitHub action source code

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

// Using the lib
KeepAliveWorkflow(githubToken, committerUsername, committerEmail, commitMessage, timeElapsed)
  .then((message) => {
    core.info(message);
    process.exit(0);
  })
  .catch((error) => {
    core.error(error);
    process.exit(1);
  });

Options

For GitHub Action

If you use the workflow as mentioned via GitHub actions following are the options available to you to customize its behavior.

Option Default Value Description Required
gh_token your default GitHub token with repo scope GitHub access token with Repo scope No
commit_message Automated commit by Keepalive Workflow to keep the repository active Commit message used while committing to the repo No
committer_username gkr-bot Username used while committing to the repo No
committer_username [email protected] Email id used while committing to the repo No
time_elapsed 50 Time elapsed from the previous commit to trigger a new automated commit (in days) No

For Javascript Library

If you are using the JS Library version of the project, please consult the function's DocString in library.js to see the list of available parameters.

License

This project uses GNU GENERAL PUBLIC LICENSE

Liked it?

Hope you liked this project, don't forget to give it a star โญ.

keepalive-workflow's People

Contributors

gautamkrishnar avatar gkr-bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.