generated from GEOS-ESM/geos-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (93 loc) · 3.67 KB
/
discover-oncomment.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Discover on demand
name: Discover CI On PR Comment
on:
issue_comment:
types: [created]
defaults:
run:
shell: bash
jobs:
bot:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
outputs:
experiment-name: ${{ steps.experience.outputs.name }}
experiment-action: ${{ steps.experience.outputs.action }}
branch: ${{ steps.get-branch.outputs.branch }}
steps:
- name: Bot help
id: check
if: contains(github.event.comment.body, '/bot help')
shell: bash
run: |
gh post commnt ${{ github.event.issue.pull_request.url }} --body "Bot commands:\n /bot experience --name=[per experiment.yaml] --action=[All, Validation, Benchmark]"
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
- name: Bot experience
id: experience
if: contains(github.event.comment.body, '/bot experience')
shell: bash
run: |
echo Launching Discover CI: ${{github.event.comment.body}}
BODY="${{github.event.comment.body}}"
EXP_NAME_DIRTY=${BODY#*--name=}
EXP_NAME=${EXP_NAME_DIRTY%% *}
echo "name=${EXP_NAME}" >> "$GITHUB_OUTPUT"
EXP_ACTION_DIRTY=${BODY#*--action=}
EXP_ACTION=${EXP_ACTION_DIRTY%% *}
echo "action=${EXP_ACTION}" >> "$GITHUB_OUTPUT"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Discover experiment started 🚀\n Parameters: ${EXP_NAME} ${EXP_ACTION}\m Url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
});
- name: Extract branch
id: 'get-branch'
run: echo ::set-output name=branch::$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
respond-to-query-as-comment:
needs: [bot]
runs-on: ubuntu-latest
steps:
- name: Acknowledge
uses: actions/github-script@v6
with:
script: |
run-discover-ondemand:
needs: bot
uses: GEOS-ESM/CI-workflows/.github/workflows/geosongpu-ondemand.yml@project/geosongpu
with:
experiment_name: ${{ needs.bot.outputs.experiment-name }}
experiment_action: ${{ needs.bot.outputs.experiment-action }}
geosongpu_ci_ref: ${{ needs.bot.outputs.branch }}
comment-results:
if: success() || failure()
needs: [run-discover-ondemand, bot]
runs-on: ubuntu-latest
steps:
- name: Message success
if: ${{ needs.run-discover-ondemand.result == 'success' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ Successful discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}',
});
- name: Message failure
if: ${{ needs.run-discover-ondemand.result != 'success' }}
uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '❌ Failed discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}',
});