-
Notifications
You must be signed in to change notification settings - Fork 0
add build-push-deploy #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hamishfagg
wants to merge
27
commits into
main
Choose a base branch
from
add/build-push-deploy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
8f30a64
initial
hamishfagg 63df8dd
fix
hamishfagg b0f0f27
fix
hamishfagg d2736ba
fix
hamishfagg 10bfe9b
fix
hamishfagg d89cc67
fix
hamishfagg 7ae5c59
fix
hamishfagg 8facb60
fix
hamishfagg 458c9f0
fix
hamishfagg bfd5d44
fix
hamishfagg 7e9a827
fix
hamishfagg 8e45f86
fix
hamishfagg f97bb17
fix
hamishfagg b5a22fd
fix
hamishfagg b855cba
fix
hamishfagg f20315e
fix
hamishfagg 318229d
fix
hamishfagg c58b909
fix
hamishfagg e0786b1
fix
hamishfagg dc832e8
fix
hamishfagg 7eb5d87
WIP
hamishfagg 2769466
add bake
hamishfagg 0594a3a
add deploy namespace
hamishfagg 5aef156
add migration
hamishfagg c7fd0f7
secret->var
hamishfagg 3b20427
log into ecr
hamishfagg 833709f
fix migrate
hamishfagg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| service-name: | ||
| description: "Name of the service to build. Used as the default image name and src dir unless 'image-name' or 'src-path' are used." | ||
| type: string | ||
| required: true | ||
| stage-name: | ||
| description: "The backend environment we are building for (API calls are pointed to). This should be one of (development, staging, production)." | ||
| type: string | ||
| required: true | ||
| docker-build-args: | ||
| description: "Extra args passed to 'docker build'." | ||
| type: string | ||
| required: false | ||
| docker-image-ref: | ||
| description: "The version number or sha used in creating image tag" | ||
| type: string | ||
| required: false | ||
| secrets: | ||
| GH_ACTIONS_SLACK_BOT_TOKEN: | ||
| required: 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 | ||
| concurrency: | ||
| group: ${{ github.workflow_ref }} | ||
| cancel-in-progress: true | ||
| environment: | ||
| name: ${{ github.event.pull_request.head.repo.fork && 'manual-approval' || '' }} | ||
| outputs: | ||
| deploy-envs: ${{ steps.get-labels.outputs.deploy-envs }} | ||
| steps: | ||
| - id: get-labels | ||
| uses: mindsdb/github-actions/get-deploy-labels@main | ||
|
|
||
| # Build our docker images based on our bake file | ||
| build: | ||
| runs-on: mdb-dev | ||
| needs: [get-deploy-labels] | ||
| if: needs.get-deploy-labels.outputs.deploy-envs != '[]' | ||
| concurrency: | ||
| group: ${{ github.workflow_ref }} | ||
| cancel-in-progress: true | ||
| env: | ||
| AWS_REGION: us-east-1 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: mindsdb/github-actions/build-push-ecr@main | ||
| with: | ||
| module-name: ${{ inputs.service-name }} | ||
| build-for-environment: ${{ inputs.stage-name }} | ||
|
|
||
| # Push cache layers to docker registry | ||
| # This is separate to the build step so we can do other stuff in parallel | ||
| # build-cache: | ||
| # name: Push Docker Cache | ||
| # runs-on: mdb-dev | ||
| # needs: [build] | ||
| # concurrency: | ||
| # group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}-cache | ||
| # cancel-in-progress: true | ||
| # 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 }} | ||
| # target: cloud-cpu | ||
| # platforms: linux/amd64 | ||
| # push-cache: true | ||
| # cache-only: true | ||
|
|
||
| # 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: | ||
| runs-on: mdb-dev | ||
| needs: [ get-deploy-labels, build ] | ||
| strategy: | ||
| matrix: | ||
| deploy-env: ${{fromJson(needs.get-deploy-labels.outputs.deploy-envs)}} | ||
| concurrency: | ||
| group: deploy-${{ matrix.deploy-env }} | ||
| cancel-in-progress: false | ||
| environment: | ||
| name: ${{ matrix.deploy-env }} | ||
| url: ${{ vars.ENV_URL }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: mindsdb/github-actions/setup-env@main | ||
| - name: Notify of deployment starting | ||
| id: slack | ||
| uses: ./github-actions/slack-deploy-msg | ||
| with: | ||
| channel-id: ${{ secrets.SLACK_DEPLOYMENTS_CHANNEL_ID }} | ||
| status: "started" | ||
| color: "#0099CC" | ||
| env-name: ${{ matrix.deploy-env }} | ||
| env-url: ${{ vars.ENV_URL }} | ||
| slack-token: ${{ secrets.GH_ACTIONS_SLACK_BOT_TOKEN }} | ||
| - uses: DevOps-Nirvana/aws-helm-multi-deploy-nodocker@v4 | ||
| with: | ||
| environment-slug: ${{matrix.deploy-env}} | ||
| k8s-namespace: ${{matrix.deploy-env}} | ||
| image-tag: ${{ inputs.stage-name }}-${{ github.sha }} | ||
| timeout: 600s | ||
| wait: "true" # We need to wait till deployment is finished here, since the calling workflow might test the deployment env | ||
| - name: Notify of deployment finish | ||
| uses: ./github-actions/slack-deploy-msg | ||
| 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.ENV_URL }} | ||
| slack-token: ${{ secrets.GH_ACTIONS_SLACK_BOT_TOKEN }} | ||
| update-message-id: ${{ steps.slack.outputs.ts }} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.