Skip to content

Commit 8f30a64

Browse files
committed
initial
1 parent aaa6bc8 commit 8f30a64

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

build-push-deploy/workflow.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
service-name:
5+
description: "Name of the service to build. Used as the default image name and src dir unless 'image-name' or 'src-path' are used."
6+
required: true
7+
environment-name:
8+
description: "The backend environment we are building for (API calls are pointed to). This should be one of (development, staging, production)."
9+
required: true
10+
docker-build-args:
11+
description: "Extra args passed to 'docker build'."
12+
required: false
13+
docker-image-ref:
14+
description: "The version number or sha used in creating image tag"
15+
required: false
16+
secrets:
17+
18+
19+
jobs:
20+
changes:
21+
name: Filter changed files
22+
runs-on: mdb-dev
23+
outputs:
24+
not-docs: ${{ steps.filter.outputs.not-docs }}
25+
concurrency:
26+
group: ${{ github.workflow_ref }}
27+
cancel-in-progress: true
28+
steps:
29+
- uses: dorny/paths-filter@v3
30+
id: filter
31+
with:
32+
predicate-quantifier: "every"
33+
filters: |
34+
not-docs:
35+
- '!docs/**'
36+
- '!**/*.md'
37+
38+
# Looks for labels like "deploy-to-<env>" attached to a PR so we can deploy to those envs
39+
get-deploy-labels:
40+
name: Get Deploy Envs
41+
runs-on: mdb-dev
42+
concurrency:
43+
group: ${{ github.workflow_ref }}
44+
cancel-in-progress: true
45+
environment:
46+
name: ${{ github.event.pull_request.head.repo.fork && 'manual-approval' || '' }}
47+
outputs:
48+
deploy-envs: ${{ steps.get-labels.outputs.deploy-envs }}
49+
steps:
50+
- id: get-labels
51+
uses: ./github-actions/get-deploy-labels
52+
53+
# Build our docker images based on our bake file
54+
build:
55+
runs-on: mdb-dev
56+
needs: [get-deploy-labels]
57+
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
58+
concurrency:
59+
group: ${{ github.workflow_ref }}
60+
cancel-in-progress: true
61+
env:
62+
AWS_REGION: us-east-1
63+
steps:
64+
- uses: ./github-actions/build-push-ecr
65+
with:
66+
module-name: ${{ inputs.service-name }}
67+
build-for-environment: development
68+
69+
# Push cache layers to docker registry
70+
# This is separate to the build step so we can do other stuff in parallel
71+
# build-cache:
72+
# name: Push Docker Cache
73+
# runs-on: mdb-dev
74+
# needs: [build]
75+
# concurrency:
76+
# group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-cache
77+
# cancel-in-progress: true
78+
# steps:
79+
# - uses: actions/checkout@v4
80+
# with:
81+
# ref: ${{ github.event.pull_request.head.sha }}
82+
# - name: Pull MindsDB Github Actions
83+
# uses: actions/checkout@v4
84+
# with:
85+
# repository: mindsdb/github-actions
86+
# path: github-actions
87+
# # Build the bakefile and push
88+
# - uses: ./github-actions/docker-bake
89+
# with:
90+
# git-sha: ${{ github.event.pull_request.head.sha }}
91+
# target: cloud-cpu
92+
# platforms: linux/amd64
93+
# push-cache: true
94+
# cache-only: true
95+
96+
# Call our deployment workflow, so long as this is not a forked PR
97+
# This will run the deployment workflow in the base branch, not in the PR.
98+
# So if you change the deploy workflow in your PR, the changes won't be reflected in this run.
99+
deploy:
100+
name: Deploy
101+
needs: [build, get-deploy-labels]
102+
if: needs.get-deploy-labels.outputs.deploy-envs != '[]'
103+
uses: ./.github/workflows/deploy.yml
104+
with:
105+
deploy-envs: ${{ needs.get-deploy-labels.outputs.deploy-envs }}
106+
image-tag: ${{ github.event.pull_request.head.sha }}
107+
secrets: inherit

0 commit comments

Comments
 (0)