Skip to content

fix(multi_format_api): explode nested JSON record arrays into rows #24

fix(multi_format_api): explode nested JSON record arrays into rows

fix(multi_format_api): explode nested JSON record arrays into rows #24

name: Build and deploy to staging
permissions:
contents: read
pull-requests: write
pages: write
id-token: write
on:
# Using pull_request instead of push on main because we want access to the pull request's details via 'github.event'
# But it means we need to check below if this PR was merged and not just closed
pull_request:
types:
- closed
branches:
- 'main'
- 'releases/*'
concurrency:
group: ${{ github.workflow_ref }}
cancel-in-progress: true
jobs:
run_unit_tests:
name: Run Unit Tests
if: github.event.pull_request.merged == true
uses: ./.github/workflows/tests_unit.yml
secrets: inherit
# Build our docker images based on our bake file
build:
if: github.event.pull_request.merged == true
name: Build Docker Images
runs-on: mdb-dev
steps:
# Check out the merge commit on the base branch
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
# Build the bakefile and push
- uses: mindsdb/github-actions/docker-bake@main
with:
push-cache: false
# 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]
steps:
# Check out the merge commit on the base branch
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
# Build the bakefile and push
- uses: mindsdb/github-actions/docker-bake@main
with:
push-cache: true
cache-only: true
# Call our deployment workflow
deploy:
name: Deploy to Staging
needs: [build]
uses: ./.github/workflows/deploy.yml
with:
deploy-envs: '["staging", "dev", "alpha-dev"]'
image-tag: ${{ github.event.pull_request.merge_commit_sha }}
secrets: inherit
# Run integration tests
run_integration_tests:
if: github.event.pull_request.merged == true
name: Run Integration Tests
needs: [deploy]
concurrency:
group: deploy-staging
cancel-in-progress: false
uses: ./.github/workflows/tests_integration.yml
with:
git-sha: ${{ github.event.pull_request.merge_commit_sha }}
deploy-env: staging
secrets: inherit
tests_completed:
if: always() && github.event.pull_request.merged == true
name: All Tests Succeeded
needs: [run_unit_tests, run_integration_tests]
runs-on: mdb-dev
steps:
- name: fail if tests failed or didnt run
if: ${{ needs.run_unit_tests.result != 'success' || needs.run_integration_tests.result != 'success'}}
run: exit 1
- run: echo "Tests ran successfully"
slack_message:
if: failure() && !cancelled() && github.event.pull_request.merged == true
name: Notify Slack
# Every previous job needs to be in here, because failure() will only return true if the job that failed is in 'needs'
needs: [run_unit_tests, build, build-cache, deploy, run_integration_tests, tests_completed]
runs-on: mdb-dev
steps:
- name: Notify of failing tests
if: ${{ needs.tests_completed.result != 'success' && needs.tests_completed.result != 'cancelled' }}
uses: slackapi/slack-github-action@v1.26.0
with:
channel-id: ${{ secrets.SLACK_ENG_CHANNEL_ID }}
payload: |
{
"attachments": [
{
"color": "#FF4444",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "TEST RUN FAILED ON ${{ github.base_ref }}",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": " "
},
"fields": [
{
"type": "mrkdwn",
"text": "*Commit*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha }}>"
},
{
"type": "mrkdwn",
"text": "*Workflow Run*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
}
]
}
]
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.GH_ACTIONS_SLACK_BOT_TOKEN }}