Skip to content

Held Suarez benchmark #27

Held Suarez benchmark

Held Suarez benchmark #27

# Discover on demand
name: Discover CI On PR Comment
on:
issue_comment:
types: [created]
defaults:
run:
shell: bash
jobs:
check-valid-comment:
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request }}
outputs:
experiment-name: ${{ steps.extractor.outputs.EXP_NAME }}
experiment-action: ${{ steps.extractor.outputs.EXP_ACTION }}
branch: ${{ steps.get-branch.outputs.branch }}
steps:
- name: Extract command
id: extractor
if: contains(github.event.comment.body, '/discover-ci')
shell: bash
run: |
echo Launching Discover CI: ${{github.event.comment.body}}
BODY="${{github.event.comment.body}}"
EXP_NAME_DIRTY=${BODY#*experiment-name=}
echo "EXP_NAME=${EXP_NAME_DIRTY%% *}" >> "$GITHUB_OUTPUT"
EXP_ACTION_DIRTY=${BODY#*experiment-action=}
echo "EXP_ACTION=${EXP_ACTION_DIRTY%% *}" >> "$GITHUB_OUTPUT"
- 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: [check-valid-comment]
runs-on: ubuntu-latest
steps:
- name: Acknowledge
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: 'Discover experiment started ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
});
run-discover-ondemand:
needs: check-valid-comment
uses: GEOS-ESM/CI-workflows/.github/workflows/geosongpu-ondemand.yml@project/geosongpu
with:
experiment_name: ${{ needs.check-valid-comment.outputs.experiment-name }}
experiment_action: ${{ needs.check-valid-comment.outputs.experiment-action }}
geosongpu_ci_ref: ${{ needs.check-valid-comment.outputs.branch }}
comment-results:
if: always()
needs: [run-discover-ondemand, check-valid-comment]
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: 'Discover experiment ${{ needs.check-valid-comment.outputs.experiment-name }}/${{ needs.check-valid-comment.outputs.experiment-action }} succeeded! ✅',
});
- 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: 'Discover experiment ${{ needs.check-valid-comment.outputs.experiment-name }}/${{ needs.check-valid-comment.outputs.experiment-action }} failed! ❌',
});