Skip to content

Commit ac9509f

Browse files
committed
add
1 parent cfb94ec commit ac9509f

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/keep-alive.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Keep Alive
2+
3+
# This workflow is designed to keep the repository active.
4+
# GitHub automatically disables all actions with a cron trigger after 60 days of inactivity.
5+
# This action checks if there has been a commit in the last 55 days.
6+
# If a commit is found within this timeframe, the workflow does nothing,
7+
# however, if no commits have been made, it performs an empty push to keep the repository active.
8+
9+
on:
10+
workflow_dispatch:
11+
schedule:
12+
- cron: '0 0 * * *' # Run at 00:00 every day
13+
push:
14+
branches:
15+
- keep-alive
16+
17+
jobs:
18+
keep_alive:
19+
runs-on: 'ubuntu-latest'
20+
permissions:
21+
contents: read
22+
actions: write
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.7
27+
28+
- name: Calculate days since last commit
29+
id: commit_date
30+
run: |
31+
LAST_COMMIT_DATE=$(git log -1 --format=%ct)
32+
echo "Last commit date: $LAST_COMMIT_DATE"
33+
34+
CURRENT_DATE=$(date +%s)
35+
echo "Current date: $CURRENT_DATE"
36+
37+
# Calculate how many days have passed since the last commit
38+
DIFFERENCE=$(( ($CURRENT_DATE - $LAST_COMMIT_DATE) / 86400 ))
39+
echo "Days since last commit: $DIFFERENCE"
40+
41+
echo "days_since_commit=$DIFFERENCE" >> $GITHUB_ENV
42+
43+
- name: Keep Alive
44+
# If 55 days have passed then execute the action which makes an empty push
45+
if: steps.commit_date.outputs.days_since_commit >= '55'
46+
uses: pagopa/dx/.github/actions/keep-alive/@main

0 commit comments

Comments
 (0)