Skip to content

workflows

workflows #1

Workflow file for this run

on:
workflow_call:
inputs:
workflow_name:
type: string
required: true
environment:
type: string
required: true
target:
type: string
required: true
env_vars:
type: string
required: true
secrets:
DATABRICKS_HOST:
required: true
DATABRICKS_CLIENT_SECRET:
required: true
DATABRICKS_CLIENT_ID:
required: true
jobs:
detect-changes:
name: 'Detect folder changes'
runs-on: ubuntu-latest
outputs:
apps-changed: ${{ steps.changes.outputs.apps }}
packages-changed: ${{ steps.changes.outputs.packages }}
changed-apps: ${{ steps.changed-apps.outputs.list }}
changed-packages: ${{ steps.changed-packages.outputs.list }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Detect changes in apps folder
id: changes
run: |
if git diff --name-only HEAD~1 | grep -q "^apps/"; then
echo "apps=true" >> $GITHUB_OUTPUT
else
echo "apps=false" >> $GITHUB_OUTPUT
fi
if git diff --name-only HEAD~1 | grep -q "^packages/"; then
echo "packages=true" >> $GITHUB_OUTPUT
else
echo "packages=false" >> $GITHUB_OUTPUT
fi
- name: Detect which specific apps changed
id: changed-apps
run: |
CHANGED_APPS=$(git diff --name-only HEAD~1 | grep "^apps/" | cut -d'/' -f2 | sort -u | tr '\n' ',' | sed 's/,$//')
if [ -n "$CHANGED_APPS" ]; then
echo "list=$CHANGED_APPS" >> $GITHUB_OUTPUT
else
echo "list=" >> $GITHUB_OUTPUT
fi
- name: Detect which specific packages changed
id: changed-packages
run: |
CHANGED_PACKAGES=$(git diff --name-only HEAD~1 | grep "^packages/" | cut -d'/' -f2 | sort -u | tr '\n' ',' | sed 's/,$//')
if [ -n "$CHANGED_PACKAGES" ]; then
echo "list=$CHANGED_PACKAGES" >> $GITHUB_OUTPUT
else
echo "list=" >> $GITHUB_OUTPUT
fi
deploy-apps:
name: 'Deploy app ${{ matrix.app }} to ${{ inputs.environment }}'
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.apps-changed == 'true' && needs.detect-changes.outputs.changed-apps != ''
strategy:
matrix:
app: ${{ fromJson(format('[{0}]', needs.detect-changes.outputs.changed-apps)) }}
steps:
- uses: actions/checkout@v3
- uses: databricks/setup-cli@main
- name: Deploy app ${{ matrix.app }}
run: |
databricks bundle deploy \
--target ${{ inputs.target }} \
--var="type_of_deployment=apps" \
--var="deployment_name=${{ matrix.app }}"
working-directory: .
env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }}
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}
${{ inputs.env_vars }}

Check failure on line 95 in .github/workflows/dabs.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/dabs.yml

Invalid workflow file

You have an error in your yaml syntax on line 95
deploy-packages:
name: 'Deploy package ${{ matrix.package }} to ${{ inputs.environment }}'
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.packages-changed == 'true' && needs.detect-changes.outputs.changed-packages != ''
strategy:
matrix:
package: ${{ fromJson(format('[{0}]', needs.detect-changes.outputs.changed-packages)) }}
steps:
- uses: actions/checkout@v3
- uses: databricks/setup-cli@main
- name: Deploy package ${{ matrix.package }}
run: |
databricks bundle deploy \
--target ${{ inputs.target }} \
--var="type_of_deployment=packages" \
--var="deployment_name=${{ matrix.package }}"
working-directory: .
env:
DATABRICKS_HOST: ${{ secrets.DATABRICKS_HOST }}
DATABRICKS_CLIENT_SECRET: ${{ secrets.DATABRICKS_CLIENT_SECRET }}
DATABRICKS_CLIENT_ID: ${{ secrets.DATABRICKS_CLIENT_ID }}
${{ inputs.env_vars }}
generate-tags:
name: 'Generate tags for ${{ matrix.item }}'
runs-on: ubuntu-latest
needs: [detect-changes, deploy-apps, deploy-packages]
if: github.ref == 'refs/heads/main' && (needs.detect-changes.outputs.apps-changed == 'true' || needs.detect-changes.outputs.packages-changed == 'true')
strategy:
matrix:
item: ${{ concat(needs.detect-changes.outputs.changed-apps, needs.detect-changes.outputs.changed-packages) }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate semantic version
id: version
run: |
# Get current timestamp for patch version
TIMESTAMP=$(date +%s)
PATCH_VERSION=$((TIMESTAMP % 1000))
# Generate semantic version
VERSION="1.0.${PATCH_VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Generated version: $VERSION"
- name: Create and push tag
run: |
TAG_NAME="${{ matrix.item }}-v${{ steps.version.outputs.version }}"
git tag $TAG_NAME
git push origin $TAG_NAME
echo "Created tag: $TAG_NAME"