forked from mindsdb/mindsdb
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (84 loc) · 3 KB
/
build_deploy_dev.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
name: Build and deploy to dev
on:
pull_request:
types: [opened, reopened, synchronize, labeled]
# Cancel any existing runs of this workflow on the same branch/pr
# We always want to build/deploy/test a new commit over an older one
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: true
jobs:
# Looks for labels like "deploy-to-<env>" attached to a PR so we can deploy to those envs
get-deploy-labels:
runs-on: mdb-dev
outputs:
deploy-envs: ${{ steps.get-labels.outputs.deploy-envs }}
steps:
- name: Pull MindsDB Github Actions
uses: actions/checkout@v4
with:
repository: mindsdb/github-actions
path: github-actions
ssh-key: ${{ secrets.GH_ACTIONS_PULL_SSH }}
- id: get-labels
uses: ./github-actions/get-deploy-labels
build:
# Build our docker images based on our bake file
runs-on: mdb-dev
needs: [get-deploy-labels]
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
steps:
- uses: actions/checkout@v4
- name: Pull MindsDB Github Actions
uses: actions/checkout@v4
with:
repository: mindsdb/github-actions
path: github-actions
ssh-key: ${{ secrets.GH_ACTIONS_PULL_SSH }}
# Build the bakefile and push
- uses: ./github-actions/docker-bake
build_cache:
# Build our docker images based on our bake file
# This job only pushes the layers to the cache repo
# It's done separately so other jobs can run without waiting for this one
runs-on: mdb-dev
needs: [build]
steps:
- uses: actions/checkout@v4
- name: Pull MindsDB Github Actions
uses: actions/checkout@v4
with:
repository: mindsdb/github-actions
path: github-actions
ssh-key: ${{ secrets.GH_ACTIONS_PULL_SSH }}
- uses: ./github-actions/docker-bake-cache
trigger_deploy:
# Trigger private repo to deploy to dev envs
runs-on: mdb-dev
needs: [build, get-deploy-labels]
strategy:
matrix:
deploy-env: ${{fromJson(needs.get-deploy-labels.outputs.deploy-envs)}}
environment:
name: dev
# 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
concurrency:
group: deploy-${{ matrix.deploy-env }}
cancel-in-progress: false
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: convictional/[email protected]
with:
owner: mindsdb
repo: INTERNAL-mindsdb-build-deploy-to-kubernetes
github_token: ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}
workflow_file_name: deploy-dev.yml
ref: main
client_payload: '{"image-tag-prefix": "${{ env.CI_SHA }}", "deploy-env": "${{matrix.deploy-env}}"}'
run_tests:
name: Run Post-Deploy Tests
needs: [trigger_deploy]
uses: ./.github/workflows/test_on_deploy.yml
secrets: inherit