From 0b11bc54e9bf923cbf812fada978f6b42a85bc00 Mon Sep 17 00:00:00 2001 From: chrisjsimpson Date: Mon, 27 Jan 2025 16:28:06 +0000 Subject: [PATCH] Fix #1444 Update git-auto-issue-branch-creation.yml --- .../git-auto-issue-branch-creation.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/.github/workflows/git-auto-issue-branch-creation.yml b/.github/workflows/git-auto-issue-branch-creation.yml index 529dc948..a7832713 100644 --- a/.github/workflows/git-auto-issue-branch-creation.yml +++ b/.github/workflows/git-auto-issue-branch-creation.yml @@ -6,6 +6,10 @@ on: jobs: create-issue-branch: runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + issues: write steps: - name: Checkout code uses: actions/checkout@v4 @@ -47,3 +51,21 @@ jobs: git checkout -b "${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}" git push -u origin HEAD + - name: Create Empty Commit to allow empty pr + run: | + git config --global user.name "nobody" + git config --global user.email "username@users.noreply.github.com" + git commit --allow-empty -m "Empty commit to allow auto PR creation" + git fetch origin + git rebase --strategy-option=theirs origin/main --verbose # thanks https://joht.github.io/johtizen/build/2022/01/20/github-actions-push-into-repository.html + git push --verbose + + - name: Creating PR based on branch name ${{ github.ref_name }} + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/KarmaComputing/create-pull-request-on-branch-creation/pulls \ + -d '{"title": "#${{ steps.issue.outputs.number }} ${{ env.ISSUE_BRANCH_NAME }}","body":"Pull request related issue: #${{ steps.issue.outputs.number }}. Please pull these awesome changes in!","head":"${{ steps.issue.outputs.number }}-${{ env.ISSUE_BRANCH_NAME }}","base":"main"}'