1
- name : Regenerate SQL Main File
1
+ name : Format and Regenerate SQL Main File
2
2
on :
3
3
push :
4
4
branches :
@@ -10,18 +10,47 @@ jobs:
10
10
runs-on : ubuntu-latest
11
11
steps :
12
12
- uses : actions/checkout@v3
13
+ with :
14
+ fetch-depth : 0
13
15
- name : Checkout Code
14
16
run : |
15
17
git config --global user.name 'Darling Data'
16
18
git config --global user.email 'erik@erikdarling.com'
17
19
git checkout
20
+ - name : Trim trailing whitespace and replace Tabs
21
+ shell : pwsh
22
+ run : |
23
+ $changedFiles = git --no-pager diff --name-only --relative --diff-filter=AM "${{ github.event.before }}" "${{ github.sha }}" -- '***.sql'
24
+ $tabSize = 4
25
+ $changedFiles | ForEach-Object {
26
+ $outputString = ""
27
+ $fullPath = $_
28
+ $Content = Get-Content $fullPath
29
+ foreach ($Ctnt in $Content) {
30
+ $CharArray = $Ctnt.ToCharArray()
31
+ $lineOutput = ""
32
+ $slidingOffset = 0
33
+ for ($charIdx = 0; $charIdx -lt $CharArray.Length; $charIdx++) {
34
+ if ($CharArray[$charIdx] -eq "`t") {
35
+ $currentTab = $tabSize - (($charIdx + $slidingOffset) % $tabSize)
36
+ $slidingOffset += $currentTab - 1
37
+ $lineOutput += (" " * $currentTab)
38
+ }
39
+ else {
40
+ $lineOutput += $CharArray[$charIdx]
41
+ }
42
+ }
43
+ $outputString += $lineOutput.TrimEnd() + "`n" # Add line output with trailing spaces removed to the output string, and add newline
44
+ }
45
+ Set-Content -Path $fullPath -Value ($outputString.TrimEnd())
46
+ }
18
47
- name : Compile SQL File
19
48
shell : pwsh
20
49
run : |
21
50
cd Install-All
22
51
./Merge-All.ps1
23
52
- name : Commit Updated File
24
53
run : |
25
- git add ./Install-All/DarlingData.sql
26
- git commit -am "Automation: Building SQL File"
27
- git push
54
+ git add .
55
+ git commit -am "Automation: Format and Build SQL File"
56
+ git push
0 commit comments