Skip to content

Keep Workflows alive #96

Keep Workflows alive

Keep Workflows alive #96

Workflow file for this run

name: Keep Workflows alive
on:
workflow_dispatch:
schedule:
- cron: '20 21 * * *'
push:
branches:
- 'main'
jobs:
keepalive-job:
name: Keepalive Workflow
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Re-enable all active workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -euo pipefail
echo "Fetching active workflows for ${GITHUB_REPOSITORY}..."
workflow_ids=$(gh api --paginate \
"repos/${GITHUB_REPOSITORY}/actions/workflows" \
--jq '.workflows[] | select(.state=="active") | .id')
if [ -z "$workflow_ids" ]; then
echo "No active workflows found."
exit 0
fi
echo "$workflow_ids" | while read -r id; do
name=$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/${id}" --jq '.name')
echo "Re-enabling workflow: ${name} (ID: ${id})"
gh api -X PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/${id}/enable"
done
echo "Done."