-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (63 loc) · 2.52 KB
/
run_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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: CheckWFRunStatus
on:
workflow_dispatch:
jobs:
test_previous_run:
runs-on: ubuntu-latest
steps:
# Step per ottenere le informazioni dell'ultima esecuzione
- name: Get last workflow run
id: get_last_run
uses: actions/github-script@v6
with:
script: |
const response = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'test_wf_run_status.yml',
per_page: 1,
});
const lastRun = response.data.workflow_runs[0];
console.log('\n\n-------------------------\n')
console.log('WORKFLOW RUNS: \n')
console.log(response.data.workflow_runs)
console.log('\n\n-------------------------\n')
console.log('Response: \n')
console.log(lastRun)
console.log(lastRun.conclusion)
core.setOutput('conclusion', lastRun.conclusion);
core.setOutput('run_id', lastRun.id)
- name: print the status
run: |
echo "${{steps.get_last_run.outputs.conclusion}}"
echo "${{steps.get_last_run.outputs.run_id}}"
# Step per controllare lo stato
# - name: Check workflow result
# if: ${{ steps.get_last_run.outputs.conclusion == 'success' }}
# run: |
# echo "Previous run was successful. No need to run the workflow today."
# exit 0 # Stop workflow run
- name: Re run last workflow
id: re_run_wf
# # if: ${{ steps.get_last_run.outputs.conclusion != 'success' }}
uses: actions/github-script@v6
env:
LAST_RUN_ID: ${{ steps.get_last_run.outputs.run_id }}
with:
script: |
console.log('In the re run last workflow step')
const { LAST_RUN_ID } = process.env
console.log(`Input run id: ${LAST_RUN_ID}`)
const response = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'test_wf_run_status.yml',
ref: 'main',
});
console.log('\n\n-------------------------\n')
console.log('RERUNNING WORKFLOW: \n')
console.log(response)
console.log('\n\n-------------------------\n')
# Step uscita
- name: Terminate workflow
run: echo "Terminating with success"