-
Notifications
You must be signed in to change notification settings - Fork 179
107 lines (103 loc) · 3.72 KB
/
opentrons-ai-production-deploy.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
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
name: 'OpentronsAI production deployment'
on:
push:
tags:
- 'ai-client@*'
- 'ai-server@*'
env:
CI: true
jobs:
deploy-client:
if: startsWith(github.ref, 'refs/tags/ai-client@')
# if there is a deployment (this workflow) in progress for the ai-client@ tag, cancel it
concurrency:
group: ${{ github.workflow }}-ai-client@
cancel-in-progress: true
runs-on: 'ubuntu-22.04'
permissions:
id-token: write
contents: read
name: 'OpentronsAI client prod deploy'
timeout-minutes: 10
steps:
- uses: 'actions/checkout@v4'
- uses: 'actions/setup-node@v4'
with:
node-version: '22.11.0'
- name: 'install udev'
run: |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.npm-cache/_prebuild
${{ github.workspace }}/.yarn-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: 'setup-js'
run: |
npm config set cache ${{ github.workspace }}/.npm-cache
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
make setup-js
- name: 'build'
env:
OT_AI_CLIENT_MIXPANEL_ID: ${{ secrets.OT_AI_CLIENT_MIXPANEL_ID }}
run: |
make -C opentrons-ai-client build-production
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PROD_AI_ROLE_ARN }}
aws-region: ${{ secrets.PROD_AI_REGION }}
- name: 'deploy client to prod'
run: |
make -C opentrons-ai-client prod-deploy
deploy-server:
if: startsWith(github.ref, 'refs/tags/ai-server@')
# if there is a deployment (this workflow) in progress for the ai-server@ tag, cancel it
concurrency:
group: ${{ github.workflow }}-ai-server@
cancel-in-progress: true
runs-on: 'ubuntu-latest'
permissions:
id-token: write
contents: read
name: 'OpentronsAI server prod deploy'
timeout-minutes: 10
steps:
- name: Extract Version
id: extract_version
run: |
TAG_REF=${{ github.ref }}
SERVER_VERSION=${TAG_REF#refs/tags/ai-server@}
echo "SERVER_VERSION=$SERVER_VERSION" >> "$GITHUB_OUTPUT"
- name: Checkout opentrons repo
uses: 'actions/checkout@v4'
- name: Setup Python
uses: 'actions/setup-python@v5'
with:
python-version: '3.12'
cache: 'pipenv'
cache-dependency-path: opentrons-ai-server/Pipfile.lock
- name: Setup
id: install
working-directory: ./opentrons-ai-server
run: make setup
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.PROD_AI_ROLE_ARN }}
aws-region: ${{ secrets.PROD_AI_REGION }}
- name: 'deploy api to prod'
working-directory: ./opentrons-ai-server
run: |
make deploy ENV=prod TAG=${{ steps.extract_version.outputs.SERVER_VERSION }}