Skip to content

Keep scheduled workflows alive #8

Keep scheduled workflows alive

Keep scheduled workflows alive #8

Workflow file for this run

name: Keep scheduled workflows alive
on:
workflow_dispatch:
schedule:
- cron: 0 0 1 * *
jobs:
keepalive:
runs-on: ubuntu-22.04
steps:
- name: Disable workflows
uses: actions/github-script@v7
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
script: |
const workflows = await github.rest.actions.listRepoWorkflows({
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const workflow of workflows.data.workflows) {
await github.rest.actions.disableWorkflow({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow.id,
});
}
- name: Enable workflows
uses: actions/github-script@v7
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
script: |
const workflows = await github.rest.actions.listRepoWorkflows({
owner: context.repo.owner,
repo: context.repo.repo,
});
for (const workflow of workflows.data.workflows) {
await github.rest.actions.enableWorkflow({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: workflow.id,
});
}