Skip to content

Commit f4bd983

Browse files
authored
Update keep-alive.yml
1 parent eb9a2bd commit f4bd983

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

.github/workflows/keep-alive.yml

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
# Issue that this yml is trying to resolve: Due to no direct interaction with repository the GitHub Action need to be renewed every 60 days.
2-
name: Keep Repository Active
3-
4-
on:
5-
schedule:
6-
- cron: "0 0 */15 * *" # Runs every 15 days
7-
workflow_dispatch: # This allows the manual "Run workflow" button
8-
9-
jobs:
10-
keep_alive:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Checkout repository
14-
uses: actions/checkout@v3
15-
with:
16-
token: ${{ secrets.GITHUB_TOKEN }}
17-
18-
- name: Keep the repository active
19-
run: echo "This action is running to prevent inactivity"
2+
name: Workflow Keepalive
3+
description: >-
4+
GitHub Action to prevent GitHub from disabling scheduled workflows due to
5+
repository inactivity
6+
branding:
7+
icon: activity
8+
color: red
9+
inputs:
10+
GITHUB_TOKEN:
11+
required: false
12+
description: >-
13+
GITHUB_TOKEN with actions: write permissions
14+
(default: github.token)
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Re-enable workflow
19+
env:
20+
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN || github.token }}
21+
shell: sh
22+
run: |
23+
case "${GITHUB_WORKFLOW_REF:?}" in
24+
"${GITHUB_REPOSITORY:?}"/.github/workflows/*.y*ml@*) ;;
25+
*) false ;;
26+
esac
27+
workflow="${GITHUB_WORKFLOW_REF%%@*}"
28+
workflow="${workflow#${GITHUB_REPOSITORY}/.github/workflows/}"
29+
gh api -X PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/${workflow}/enable"

0 commit comments

Comments
 (0)