-
Notifications
You must be signed in to change notification settings - Fork 1
32 lines (30 loc) · 996 Bytes
/
check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Restart Discord Bot
on:
schedule:
# Запускать каждые 10 минут
- cron: '*/10 * * * *'
jobs:
restart:
runs-on: ubuntu-latest
steps:
- name: CheckBotStatus and Restart
uses: actions/github-script@v5
with:
script: |
const workflowRuns = await github.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy'
});
const lastRun = workflowRuns.data.workflow_runs[0];
console.log(lastRun.status);
if (lastRun.status === 'completed') {
console.log('Bot is already running');
} else {
await github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy',
});
console.log('Restarting Discord Bot...');
}