generated from GEOS-ESM/geos-template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
112 lines (104 loc) · 4.22 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
101
102
103
104
105
106
107
108
109
110
111
112
# 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: Cancel job if needed
id: conditional-cancel
if: "!contains(github.event.comment.body, '/bot')"
shell: bash
run: |
gh run --repo $REPO cancel ${{ github.run_id }}
gh run --repo $REPO watch ${{ github.run_id }}
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bot help
id: check
if: contains(github.event.comment.body, '/bot help')
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body 'Bot commands:
/bot help
: Print this message
/bot experience --name=[per experiment.yaml] --action=[All, Validation, Benchmark]
: Triggers a geosongpu_dispatch command with given parameters'
gh run --repo $REPO cancel ${{ github.run_id }}
gh run --repo $REPO watch ${{ github.run_id }}
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- 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"
gh pr comment $PR_NO --repo $REPO --body 'Discover experiment started 🚀:
Parameters: '"$EXP_NAME"' '"$EXP_ACTION"'
Url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch
id: 'get-branch'
run: |
BRANCH=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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:
#Run the job everytime _but_ when upstream has been cancelled
if: success() || failure()
needs: [run-discover-ondemand, bot]
runs-on: ubuntu-latest
steps:
- name: Message success
if: ${{ needs.run-discover-ondemand.result == 'success' }}
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body '✅ Successful discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Message failure
if: ${{ needs.run-discover-ondemand.result != 'success' }}
shell: bash
run: |
gh pr comment $PR_NO --repo $REPO --body '✅ Successful discover experiment ${{ needs.bot.outputs.experiment-name }} @ ${{ needs.bot.outputs.experiment-action }}'
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}