-
Notifications
You must be signed in to change notification settings - Fork 4
/
apply.yml
83 lines (79 loc) · 2.86 KB
/
apply.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Rollout Database Scripts
on:
push:
branches: [ main ]
paths:
- 'schema/**'
workflow_dispatch:
permissions:
id-token: write
contents: read
packages: read
jobs:
get-changed-directories:
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.get-changed-directories.outputs.any_changed }}
changed_directories: ${{ steps.set-matrix-changed-directories.outputs.changed_directories }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get changed directories
id: get-changed-directories
uses: tj-actions/changed-files@cbda684547adc8c052d50711417fa61b428a9f88
with:
files: |
kusto/**/*.{yml,yaml,kql}
dir_names: 'true'
dir_names_max_depth: '3'
- name: Create matrix array of changed directories
if: steps.get-changed-directories.outputs.any_changed == 'true'
id: set-matrix-changed-directories
env:
ALL_CHANGED_FILES: ${{ steps.get-changed-directories.outputs.all_changed_files }}
run: |
echo "One or more configuration directories have changed."
echo "Changed configuration directories: ${{ steps.get-changed-directories.outputs.all_changed_files }}"
cdirs=$(echo $ALL_CHANGED_FILES | tr ' ' '\n' | sed 's/.*/"&"/' | paste -s -d ',' - | sed 's/.*/[&]/' | sed 's/,/, /g')
echo "changed_directories=${cdirs}" >> "$GITHUB_OUTPUT"
# This is the new job, only runs on changed directories.
sync-dynamic-workflows:
name: Apply
if: |
needs.get-changed-directories.outputs.any_changed == 'true' &&
vars.LEGACY_SYNC_MODE == 'false'
runs-on: ubuntu-latest
needs: get-changed-directories
container:
image: ghcr.io/github/KustoSchemaToolsAction:main
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
strategy:
matrix:
directory: ${{ fromJSON(needs.get-changed-directories.outputs.changed_directories) }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Azure OIDC Login'
uses: azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d
with:
client-id: ${{ vars.AZURE_CLIENT_ID_OIDC }}
tenant-id: ${{ vars.AZURE_TENANT_ID_OIDC }}
allow-no-subscriptions: true
- name: Set variables
shell: bash
run: |
IFS='/' read -ra DIR <<< ${{ matrix.directory }}
echo "CLUSTER=${DIR[1]}" >> $GITHUB_ENV
echo "DATABASE=${DIR[2]}" >> $GITHUB_ENV
- name: Apply changes to database
uses: ./.github/actions/KustoSchemaTools
id: KustoSchemaTools
with:
mode: apply
path: kusto
cluster: ${{ env.CLUSTER }}
database: ${{ env.DATABASE }}