99 lines (91 loc) · 3.11 KB
/
build_deploy_prod.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
94
95
96
97
98
99
name: Build and deploy release
on:
release:
types: [published]
paths-ignore:
- 'docs/**'
- 'README.md'
jobs:
check-version:
runs-on: [self-hosted, dev]
if: github.actor != 'mindsdbadmin'
steps:
- uses: actions/checkout@v3.5.3
# Get clean environment variables via https://github.com/marketplace/actions/github-environment-variables-action
- uses: FranzDiebold/github-env-vars-action@v2
- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}
- name: Check Version
run: |
PYTHONPATH=./ python tests/scripts/check_version.py ${{ env.CI_REF_NAME }} ${{ github.event.release.prerelease }}
deploy_to_pypi:
runs-on: [self-hosted, dev]
needs: check-version
if: github.actor != 'mindsdbadmin'
steps:
- uses: actions/checkout@v3.5.3
- name: Set up Python
uses: actions/setup-python@v4.7.0
with:
python-version: ${{ vars.CI_PYTHON_VERSION }}
- name: Install dependencies
run: |
pip install -r requirements/requirements-dev.txt
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
# This uses the version string from __about__.py, which we checked matches the git tag above
python setup.py sdist
twine upload dist/*
docker_build:
# Build our docker images based on our bake file
# This will tag with the release version tag and push to both dockerhub and ECR
runs-on: [self-hosted, dev]
needs: [check-version]
if: github.actor != 'mindsdbadmin'
steps:
- uses: actions/checkout@v2
- name: Docker Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Build the bakefile and push
- uses: ./.github/actions/docker-bake
with:
push-to-dockerhub: true
docker_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: [self-hosted, dev]
needs: [docker_build]
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/docker-bake-cache
trigger_deploy:
# Trigger private repo to deploy to prod env
runs-on: [self-hosted, dev]
needs: docker_build
if: github.actor != 'mindsdbadmin'
environment:
name: prod
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- uses: convictional/trigger-workflow-and-wait@v1.6.5
with:
owner: mindsdb
repo: INTERNAL-mindsdb-build-deploy-to-kubernetes
github_token: ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}
workflow_file_name: deploy-prod.yml
ref: main
client_payload: '{"image-tag-prefix": "${{ env.CI_REF_NAME }}", "deploy-env": "prod"}'
run_tests:
name: Run Post-Deploy Tests
needs: [trigger_deploy]
uses: ./.github/workflows/test_on_deploy.yml
secrets: inherit