Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gautamkrishnar/keepalive-workflow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5b3128727d02fe1a892d0a2987517c9ec8ca7425
Choose a base ref
...
head repository: gautamkrishnar/keepalive-workflow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 306efe4fc63923e36571682b4f4b3e3eee8b6625
Choose a head ref
  • 14 commits
  • 11 files changed
  • 4 contributors

Commits on Jan 26, 2024

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bdb9791 View commit details

Commits on Feb 17, 2024

  1. 3

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    539e3e3 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    ff992bf View commit details
  3. fixed type bug

    gautamkrishnar committed Feb 17, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    c94f46b View commit details
  4. update docs

    gautamkrishnar committed Feb 17, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    6938194 View commit details

Commits on Feb 18, 2024

  1. update docs

    gautamkrishnar committed Feb 18, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    0092851 View commit details
  2. [skip-ci] Published 1.2.4

    gkr-bot committed Feb 18, 2024
    Copy the full SHA
    e7ad16f View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    59bbafc View commit details
  4. [skip-ci] Published 1.2.5

    gkr-bot committed Feb 18, 2024
    Copy the full SHA
    a7e4440 View commit details

Commits on Feb 20, 2024

  1. Update README.md

    gautamkrishnar authored Feb 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4d05f5f View commit details
  2. use default gh api url

    gautamkrishnar committed Feb 20, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    dbd7721 View commit details
  3. add liskin as a contributor for ideas (#24)

    * update README.md [skip ci]
    
    * update .all-contributorsrc [skip ci]
    
    ---------
    
    Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
    allcontributors[bot] authored Feb 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ad5954e View commit details

Commits on Feb 22, 2024

  1. 2

    Verified

    This commit was signed with the committer’s verified signature.
    gautamkrishnar Gautam krishna R
    Copy the full SHA
    417cbc2 View commit details
  2. [skip-ci] Published 1.2.6

    gkr-bot committed Feb 22, 2024
    Copy the full SHA
    306efe4 View commit details
Showing with 23,525 additions and 6,143 deletions.
  1. +9 −0 .all-contributorsrc
  2. +1 −1 .github/workflows/npm-publish.yml
  3. +1 −1 .github/workflows/version-bump.yml
  4. +60 −23 README.md
  5. +4 −0 action.yml
  6. +22,891 −15 dist/index.js
  7. +25 −8 index.js
  8. +73 −21 library.js
  9. +6 −7 package.json
  10. +32 −2 util.js
  11. +423 −6,065 yarn.lock
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -72,6 +72,15 @@
"contributions": [
"code"
]
},
{
"login": "liskin",
"name": "Tomáš Janoušek",
"avatar_url": "https://avatars.githubusercontent.com/u/300342?v=4",
"profile": "https://lisk.in/",
"contributions": [
"ideas"
]
}
],
"contributorsPerLine": 7,
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "20"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn publish
2 changes: 1 addition & 1 deletion .github/workflows/version-bump.yml
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "20"
cache: "yarn"
- name: Install dependancies
run: yarn install
83 changes: 60 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,34 +7,32 @@ GitHub will suspend the scheduled trigger for GitHub action workflows if there i
![preview](https://user-images.githubusercontent.com/8397274/105174930-4303e100-5b49-11eb-90ed-95a55697582f.png)

### 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 workflow will automatically create a dummy commit (or use the GitHub API) 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)
There are three ways you can consume this library in your GitHub actions
### Dummy Commit Keepalive Workflow (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.

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

permissions:
contents: write
jobs:
cronjob-based-github-action:
name: Cronjob based github action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# - step1
# - step 2
# - step n, use it as the last step
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
```
Go to repository settings, Click on Actions > General. Update the "Workflow permissions" to "Read and write permissions". Click on save.
![Workflow permissions](https://github.com/gautamkrishnar/blog-post-workflow/assets/8397274/26d4c089-dc58-4309-b65a-2acb9a3c08ba)
<details>
<summary>Let's take an example of [Waka Readme](https://github.com/athul/waka-readme)</summary>
@@ -51,16 +49,38 @@ jobs:
name: Update this repo's README
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: athul/waka-readme@master
with:
WAKATIME_API_KEY: ${{ secrets.WAKATIME_API_KEY }}
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
```
</details>
### 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](https://www.npmjs.com/package/keepalive-workflow). Make sure that your GitHub action uses checkout action since this library needs it as a dependency.
### GitHub API Keepalive Workflow (For GitHub Actions users)
If you do not want dummy commits in your repository's commit history, you can use the library's GitHub API mode. Use the following yaml file.
```yaml
name: Github Action with a cronjob trigger
on:
schedule:
- cron: "0 0 * * *"
permissions:
actions: write
jobs:
cronjob-based-github-action:
name: Cronjob based github action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - step 2
# - step n, use it as the last step
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow in api mode
with:
use_api: true
```
### Using via NPM (For GitHub Actions developers)
For developers creating GitHub actions, you can consume the library in your javascript-based GitHub action by installing it from [NPM](https://www.npmjs.com/package/keepalive-workflow). 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
@@ -77,9 +97,9 @@ yarn add keepalive-workflow
#### Use it in your own GitHub action source code
```javascript
const core = require('@actions/core');
const { KeepAliveWorkflow } = require('keepalive-workflow');
const { KeepAliveWorkflow, APIKeepAliveWorkflow } = require('keepalive-workflow');

// Using the lib
// Using the lib in Dummy commits mode
KeepAliveWorkflow(githubToken, committerUsername, committerEmail, commitMessage, timeElapsed)
.then((message) => {
core.info(message);
@@ -89,24 +109,38 @@ KeepAliveWorkflow(githubToken, committerUsername, committerEmail, commitMessage,
core.error(error);
process.exit(1);
});

// Using the lib in GitHub API mode
APIKeepAliveWorkflow(githubToken, {
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_email` | `gkr@tuta.io` | 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 |
| `auto_push` | `true` | Defines if the workflow pushes the changes automatically | No |
| `auto_write_check` | `false` | Specifies whether the workflow will verify the repository's write access privilege for the token before executing | No |
| 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_email` | `gkr@tuta.io` | 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 |
| `auto_push` | `true` | Defines if the workflow pushes the changes automatically | No |
| `auto_write_check` | `false` | Specifies whether the workflow will verify the repository's write access privilege for the token before executing | No |
| `use_api` | `false` | Instead of using dummy commits, workflow uses GitHub API to keep the repository active. | No |


### For Javascript Library
If you are using the JS Library version of the project, please consult the function's DocString in [library.js](library.js) to see the list of available parameters.
If you are using the JS Library version of the project, please consult the function's DocStrings in [library.js](library.js) to see the list of available parameters.


### FAQs and Common issues
@@ -130,6 +164,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/kaovilai"><img src="https://avatars.githubusercontent.com/u/11228024?v=4?s=100" width="100px;" alt="Tiger Kaovilai"/><br /><sub><b>Tiger Kaovilai</b></sub></a><br /><a href="https://github.com/gautamkrishnar/keepalive-workflow/commits?author=kaovilai" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Howard20181"><img src="https://avatars.githubusercontent.com/u/40033067?v=4?s=100" width="100px;" alt="Howard Wu"/><br /><sub><b>Howard Wu</b></sub></a><br /><a href="https://github.com/gautamkrishnar/keepalive-workflow/commits?author=Howard20181" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://lisk.in/"><img src="https://avatars.githubusercontent.com/u/300342?v=4?s=100" width="100px;" alt="Tomáš Janoušek"/><br /><sub><b>Tomáš Janoušek</b></sub></a><br /><a href="#ideas-liskin" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
</tbody>
</table>

4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -31,6 +31,10 @@ inputs:
description: "Specifies whether the workflow will verify the repository's write access privilege for the token before executing"
default: "false"
required: false
use_api:
description: "Instead of using dummy commits, workflow uses GitHub API to keep the repository active. This will keep your commit history clean. Make sure you set a gh_token with actions:write permission. This wont work with the default GitHub actions token"
default: "false"
required: false

runs:
using: node20
Loading