From 0fc6ae0d168aaad198339cbf7b7f50933fd98ab7 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Tue, 17 Feb 2026 11:46:23 -0500 Subject: [PATCH] Switch build automation to PR-based workflow Replace direct push to main with peter-evans/create-pull-request so the automation respects branch protection rules. Allow the automation/format-and-build branch in the PR source check. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/build-sqlfile.yml | 28 ++++++++++++++-------------- .github/workflows/main-dev.yml | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-sqlfile.yml b/.github/workflows/build-sqlfile.yml index aadacac0..acbb88f2 100644 --- a/.github/workflows/build-sqlfile.yml +++ b/.github/workflows/build-sqlfile.yml @@ -5,6 +5,7 @@ on: - main permissions: contents: write + pull-requests: write jobs: build-sql-file: runs-on: ubuntu-latest @@ -13,11 +14,6 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.PAT_TOKEN }} - - name: Checkout Code - run: | - git config --global user.name 'Darling Data' - git config --global user.email 'erik@erikdarling.com' - git checkout - name: Trim trailing whitespace and replace Tabs shell: pwsh run: | @@ -35,23 +31,27 @@ jobs: if ($CharArray[$charIdx] -eq "`t") { $currentTab = $tabSize - (($charIdx + $slidingOffset) % $tabSize) $slidingOffset += $currentTab - 1 - $lineOutput += (" " * $currentTab) + $lineOutput += (" " * $currentTab) } else { - $lineOutput += $CharArray[$charIdx] + $lineOutput += $CharArray[$charIdx] } } $outputString += $lineOutput.TrimEnd() + "`n" # Add line output with trailing spaces removed to the output string, and add newline } Set-Content -Path $fullPath -Value ($outputString.TrimEnd()) - } + } - name: Compile SQL File shell: pwsh - run: | + run: | cd Install-All ./Merge-All.ps1 - - name: Commit Updated File - run: | - git add . - git commit -am "Automation: Format and Build SQL File" - git push \ No newline at end of file + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.PAT_TOKEN }} + commit-message: "Automation: Format and Build SQL File" + branch: automation/format-and-build + title: "Automation: Format and Build SQL File" + body: "Auto-generated formatting and rebuild of Install-All/DarlingData.sql" + delete-branch: true \ No newline at end of file diff --git a/.github/workflows/main-dev.yml b/.github/workflows/main-dev.yml index 4f6babf8..bf08b047 100644 --- a/.github/workflows/main-dev.yml +++ b/.github/workflows/main-dev.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Check branches run: | - if [ ${{ github.head_ref }} != "dev" ] && [ ${{ github.base_ref }} == "main" ]; then - echo "Merge requests to main branch are only allowed from dev branch." + if [ ${{ github.head_ref }} != "dev" ] && [ ${{ github.head_ref }} != "automation/format-and-build" ] && [ ${{ github.base_ref }} == "main" ]; then + echo "Merge requests to main branch are only allowed from dev or automation branches." exit 1 fi