1- name : ${{ inputs.workflow_name }}
2-
3- concurrency : 1
4-
51on :
6- ${{ inputs.trigger_type }} :
7- ${{ inputs.trigger_config }}
2+ workflow_call :
3+ inputs :
4+ workflow_name :
5+ type : string
6+ required : true
7+ environment :
8+ type : string
9+ required : true
10+ target :
11+ type : string
12+ required : true
13+ env_vars :
14+ type : string
15+ required : true
816
917jobs :
1018 detect-changes :
@@ -18,19 +26,17 @@ jobs:
1826 steps :
1927 - uses : actions/checkout@v3
2028 with :
21- fetch-depth : 2 # Only need 2 commits for squash commit comparison
29+ fetch-depth : 2
2230
2331 - name : Detect changes in apps folder
2432 id : changes
2533 run : |
26- # Check if apps folder has changes
2734 if git diff --name-only HEAD~1 | grep -q "^apps/"; then
2835 echo "apps=true" >> $GITHUB_OUTPUT
2936 else
3037 echo "apps=false" >> $GITHUB_OUTPUT
3138 fi
3239
33- # Check if packages folder has changes
3440 if git diff --name-only HEAD~1 | grep -q "^packages/"; then
3541 echo "packages=true" >> $GITHUB_OUTPUT
3642 else
4046 - name : Detect which specific apps changed
4147 id : changed-apps
4248 run : |
43- # Get list of changed app directories
4449 CHANGED_APPS=$(git diff --name-only HEAD~1 | grep "^apps/" | cut -d'/' -f2 | sort -u | tr '\n' ',' | sed 's/,$//')
4550 if [ -n "$CHANGED_APPS" ]; then
4651 echo "list=$CHANGED_APPS" >> $GITHUB_OUTPUT
5156 - name : Detect which specific packages changed
5257 id : changed-packages
5358 run : |
54- # Get list of changed package directories
5559 CHANGED_PACKAGES=$(git diff --name-only HEAD~1 | grep "^packages/" | cut -d'/' -f2 | sort -u | tr '\n' ',' | sed 's/,$//')
5660 if [ -n "$CHANGED_PACKAGES" ]; then
5761 echo "list=$CHANGED_PACKAGES" >> $GITHUB_OUTPUT
6973 app : ${{ fromJson(format('[{0}]', needs.detect-changes.outputs.changed-apps)) }}
7074 steps :
7175 - uses : actions/checkout@v3
72-
7376 - uses : databricks/setup-cli@main
74-
75- - name : Validate Bundle app ${{ matrix.app }}
76- run : |
77- databricks bundle validate \
78- --target ${{ inputs.target }} \
79- --var="type_of_deployment=apps" \
80- --var="deployment_name=${{ matrix.app }}"
81- working-directory : .
82- env :
83- ${{ inputs.env_vars }}
84-
85-
8677 - name : Deploy app ${{ matrix.app }}
8778 run : |
8879 databricks bundle deploy \
@@ -103,26 +94,47 @@ jobs:
10394 package : ${{ fromJson(format('[{0}]', needs.detect-changes.outputs.changed-packages)) }}
10495 steps :
10596 - uses : actions/checkout@v3
106-
10797 - uses : databricks/setup-cli@main
108-
109- - name : Validate Bundle package ${{ matrix.package }}
110-
98+ - name : Deploy package ${{ matrix.package }}
11199 run : |
112- databricks bundle validate \
100+ databricks bundle deploy \
113101 --target ${{ inputs.target }} \
114102 --var="type_of_deployment=packages" \
115103 --var="deployment_name=${{ matrix.package }}"
116104 working-directory : .
117105 env :
118106 ${{ inputs.env_vars }}
119107
120- - name : Deploy package ${{ matrix.package }}
108+ generate-tags :
109+ name : ' Generate tags for ${{ matrix.item }}'
110+ runs-on : ubuntu-latest
111+ needs : [detect-changes, deploy-apps, deploy-packages]
112+ if : github.ref == 'refs/heads/main' && (needs.detect-changes.outputs.apps-changed == 'true' || needs.detect-changes.outputs.packages-changed == 'true')
113+ strategy :
114+ matrix :
115+ item : ${{ concat(needs.detect-changes.outputs.changed-apps, needs.detect-changes.outputs.changed-packages) }}
116+ steps :
117+ - uses : actions/checkout@v3
118+ with :
119+ fetch-depth : 0
120+ token : ${{ secrets.GITHUB_TOKEN }}
121+
122+ - name : Generate semantic version
123+ id : version
121124 run : |
122- databricks bundle deploy \
123- --target ${{ inputs.target }} \
124- --var="type_of_deployment=packages" \
125- --var="deployment_name=${{ matrix.package }}"
126- working-directory : .
127- env :
128- ${{ inputs.env_vars }}
125+ # Get current timestamp for patch version
126+ TIMESTAMP=$(date +%s)
127+ PATCH_VERSION=$((TIMESTAMP % 1000))
128+
129+ # Generate semantic version
130+ VERSION="1.0.${PATCH_VERSION}"
131+
132+ echo "version=$VERSION" >> $GITHUB_OUTPUT
133+ echo "Generated version: $VERSION"
134+
135+ - name : Create and push tag
136+ run : |
137+ TAG_NAME="${{ matrix.item }}-v${{ steps.version.outputs.version }}"
138+ git tag $TAG_NAME
139+ git push origin $TAG_NAME
140+ echo "Created tag: $TAG_NAME"
0 commit comments