Skip to content

Commit

Permalink
updated with best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamkrishnar committed Feb 22, 2024
1 parent ad5dfd5 commit 971c146
Showing 1 changed file with 55 additions and 1 deletion.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ This will keep the cronjob trigger active so that it will run indefinitely witho
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:
Expand All @@ -33,6 +32,34 @@ jobs:
# - step n, use it as the last step
- uses: gautamkrishnar/keepalive-workflow@v1 # using the workflow with default settings
```
Moving the keepalive workflow into its own distinct job is strongly recommended for better security. For example:
```yaml
name: Github Action with a cronjob trigger
on:
schedule:
- cron: "0 0 * * *"
jobs:
main-job:
name: Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - step1
# - step 2
# - Step N
keepalive-job:
name: Keepalive Workflow
if: ${{ always() }}
needs: main-job
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: gautamkrishnar/keepalive-workflow@v1
```
<details>
<summary>Let's take an example of [Waka Readme](https://github.com/athul/waka-readme)</summary>
Expand Down Expand Up @@ -79,6 +106,33 @@ jobs:
use_api: true
```
Moving the keepalive workflow into its own distinct job is strongly recommended here as well, for better security:
```yaml
name: Github Action with a cronjob trigger
on:
schedule:
- cron: "0 0 * * *"
jobs:
main-job:
name: Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - step1
# - step 2
# - Step N
keepalive-job:
name: Keepalive Workflow
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- uses: actions/checkout@v4
- uses: gautamkrishnar/keepalive-workflow@v1
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.
Expand Down

0 comments on commit 971c146

Please sign in to comment.