-
Notifications
You must be signed in to change notification settings - Fork 6.2k
107 lines (102 loc) · 3.42 KB
/
deploy.yml
File metadata and controls
107 lines (102 loc) · 3.42 KB
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
permissions:
contents: read
on:
workflow_call:
inputs:
deploy-envs:
required: true
type: string
image-tag:
required: true
type: string
prod:
required: false
type: boolean
default: false
secrets:
SLACK_DEPLOYMENTS_CHANNEL_ID:
required: true
REPO_DISPATCH_PAT_TOKEN:
required: true
MINDSDB_DB_URI:
required: true
jobs:
migrate:
if: github.actor != 'mindsdbadmin'
runs-on: ${{ matrix.deploy-env == 'prod' && 'mdb-prod' || 'mdb-dev' }}
strategy:
fail-fast: false
matrix:
deploy-env: ${{ fromJson(inputs.deploy-envs) }}
concurrency:
group: deploy-${{ matrix.deploy-env }}
cancel-in-progress: false
environment:
name: ${{ matrix.deploy-env }}
url: ${{ vars.MDB_ENV_URL }}
# We only want to run one deploy job for an env at a time
# Don't cancel in progress jobs because it may be for a different PR
env:
MINDSDB_DB_CON: ${{ secrets.MINDSDB_DB_URI }}
UV_LINK_MODE: "symlink"
steps:
- uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
# Place cache in the tool dir because we mount this in our runnners
cache-local-path: "/home/runner/_work/_tool/uv-local-cache"
prune-cache: false
python-version: ${{ vars.CI_PYTHON_VERSION || '3.11' }}
- name: Install dependencies
run: |
uv pip install -r requirements/requirements.txt
- name: Migrate DB
run: |
cd mindsdb/migrations
env PYTHONPATH=../../ alembic upgrade head
# Trigger private repo to deploy
trigger_deploy:
if: github.actor != 'mindsdbadmin'
needs: migrate
runs-on: mdb-dev
strategy:
fail-fast: false
matrix:
deploy-env: ${{ fromJson(inputs.deploy-envs) }}
concurrency:
group: deploy-${{ matrix.deploy-env }}
cancel-in-progress: false
environment:
name: ${{ matrix.deploy-env }}
url: ${{ vars.MDB_ENV_URL }}
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- name: Notify of deployment starting
id: slack
uses: mindsdb/github-actions/slack-deploy-msg@main
with:
channel-id: ${{ secrets.SLACK_DEPLOYMENTS_CHANNEL_ID }}
status: "started"
color: "#0099CC"
env-name: ${{ matrix.deploy-env }}
env-url: ${{ vars.MDB_ENV_URL }}
slack-token: ${{ secrets.GH_ACTIONS_SLACK_BOT_TOKEN }}
- uses: mindsdb/github-actions/dispatch-and-wait@main
with:
owner: mindsdb
repo: INTERNAL-mindsdb-build-deploy-to-kubernetes
token: ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}
workflow: ${{ inputs.prod && 'deploy-prod.yml' || 'deploy-dev.yml' }}
workflow_inputs: '{"image-tag-prefix": "${{ inputs.image-tag }}", "deploy-env": "${{ matrix.deploy-env }}"}'
- name: Notify of deployment finish
uses: mindsdb/github-actions/slack-deploy-msg@main
if: always()
with:
channel-id: ${{ secrets.SLACK_DEPLOYMENTS_CHANNEL_ID }}
status: "${{ job.status == 'success' && 'finished' || 'failed' }}"
color: "${{ job.status == 'success' && '#00C851' || '#FF4444' }}"
env-name: ${{ matrix.deploy-env }}
env-url: ${{ vars.MDB_ENV_URL }}
slack-token: ${{ secrets.GH_ACTIONS_SLACK_BOT_TOKEN }}
update-message-id: ${{ steps.slack.outputs.ts }}