forked from mindsdb/mindsdb
-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (85 loc) · 2.97 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
92
93
name: Build and deploy to dev
on:
pull_request_target:
types: [opened, reopened, synchronize, labeled]
branches:
- 'main'
# 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:
name: Get Deploy Envs
runs-on: mdb-dev
environment:
name: ${{ github.event.pull_request.head.repo.fork && 'manual-approval' || '' }}
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
- id: get-labels
uses: ./github-actions/get-deploy-labels
# Build our docker images based on our bake file
build:
name: Build Docker Images
runs-on: mdb-dev
needs: [get-deploy-labels]
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Pull MindsDB Github Actions
uses: actions/checkout@v4
with:
repository: mindsdb/github-actions
path: github-actions
# Build the bakefile and push
- uses: ./github-actions/docker-bake
with:
git-sha: ${{ github.event.pull_request.head.sha }}
# 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
build_cache:
name: Build Docker Cache
runs-on: mdb-dev
needs: [build]
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Pull MindsDB Github Actions
uses: actions/checkout@v4
with:
repository: mindsdb/github-actions
path: github-actions
- uses: ./github-actions/docker-bake-cache
with:
git-sha: ${{ github.event.pull_request.head.sha }}
# Call our deployment workflow, so long as this is not a forked PR
# This will run the deployment workflow in the base branch, not in the PR.
# So if you change the deploy workflow in your PR, the changes won't be reflected in this run.
deploy:
name: Deploy
needs: [build, get-deploy-labels]
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
uses: ./.github/workflows/deploy.yml
with:
deploy-envs: ${{ needs.get-deploy-labels.outputs.deploy-envs }}
image-tag: ${{ github.event.pull_request.head.sha }}
secrets: inherit
# Run integration tests
# TODO: Run these against the deployed environment
run_tests:
name: Run Integration Tests
needs: [deploy]
uses: ./.github/workflows/test_on_deploy.yml
secrets: inherit