diff --git a/.github/workflows/promote-pending-sql.yml b/.github/workflows/promote-pending-sql.yml index 5bbfbac1ba..475ef26c67 100644 --- a/.github/workflows/promote-pending-sql.yml +++ b/.github/workflows/promote-pending-sql.yml @@ -9,6 +9,7 @@ on: permissions: contents: write + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -29,9 +30,14 @@ jobs: shell: pwsh run: ./tools/dev/promote_pending_updates.ps1 -Apply - - name: Commit promoted SQL updates + - name: Open promoted SQL pull request shell: pwsh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | + $branchName = "automation/promote-pending-sql-${{ github.run_id }}" + + git switch -c $branchName git add -A sql/pending_updates sql/updates $changes = git status --porcelain @@ -46,4 +52,23 @@ jobs: git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git commit -m "SQL: Promote pending updates" - git push origin HEAD:${{ github.ref_name }} + git push origin HEAD:refs/heads/$branchName + + $headers = @{ + Authorization = "Bearer $env:GITHUB_TOKEN" + Accept = "application/vnd.github+json" + "X-GitHub-Api-Version" = "2022-11-28" + } + $body = @{ + title = "SQL: Promote pending updates" + head = $branchName + base = "${{ github.ref_name }}" + body = "Automated promotion from sql/pending_updates into sql/updates." + } | ConvertTo-Json + + Invoke-RestMethod ` + -Method Post ` + -Uri "https://api.github.com/repos/${{ github.repository }}/pulls" ` + -Headers $headers ` + -Body $body ` + -ContentType "application/json"