-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromote.yaml
56 lines (48 loc) · 1.71 KB
/
promote.yaml
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
name: promote
on: issue_comment
permissions:
contents: read
issues: write
pull-requests: write
deployments: write
jobs:
ghapi-exercise:
if: (github.event.issue.pull_request != null) && contains(github.event.comment.body, '/deploy')
runs-on: ubuntu-latest
steps:
- name: Get repo contents
uses: actions/checkout@v3
- name: install dependencies
run: pip install ghapi wandb
- name: Parse value from the command
id: get-runid-value
shell: python
run: |
import re, os
comment = os.getenv('PR_COMMENT', '')
match = re.search('/deploy[\s+](\S+)', comment)
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
if match:
print(f'VAL_FOUND=true', file=f)
print(f'RUN_ID={match.group(1)}', file=f)
else:
print(f'VAL_FOUND=false', file=f)
env:
PR_COMMENT: ${{ github.event.comment.body }}
- name: Promote model to the registry
if: steps.get-runid-value.outputs.VAL_FOUND == 'true'
id: wandb-promote
run: python ./client/promote_model.py
env:
WANDB_API_KEY: ${{ secrets.WANDB_API_KEY }}
WANDB_RUN_ID: "${{ steps.get-runid-value.outputs.RUN_ID }}"
WANDB_RUN_PATH: "hamelsmu/cicd_demo/"
WANDB_REGISTRY_PATH: "av-team/model-registry/BDD Semantic Segmentation"
- name: Create a deployment
if: steps.wandb-promote.outcome == 'success'
run: python ./client/deploy.py
env:
REPO: "${{ github.repository }}"
WANDB_RUN_ID: "${{ steps.get-runid-value.outputs.RUN_ID }}"
PR_NUM: "${{ github.issue.number }}"
REGISTRY_URL: "${{ steps.wandb-promote.outputs.REGISTRY_URL }}"