From d92c04ca67d84e6b9bda9d6eba22fdb73761697d Mon Sep 17 00:00:00 2001 From: Cycle Bai <168964798+CycleBai@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:54:03 +1000 Subject: [PATCH] ci: Fix errors --- .github/workflows/auto_pr.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/auto_pr.yml b/.github/workflows/auto_pr.yml index d640cef..36df1f7 100644 --- a/.github/workflows/auto_pr.yml +++ b/.github/workflows/auto_pr.yml @@ -65,24 +65,30 @@ jobs: - name: Create Pull Request if: env.branch_exists == 'false' - uses: peter-evans/create-pull-request@v3 + uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ env.branch_name }} base: main title: "Auto PR from ${{ env.branch_name }}" body: "This is an automated PR created from ${{ env.branch_name }}" + draft: false # Ensure the PR is not a draft - - name: Get PR number - if: env.branch_exists == 'true' - id: get_pr_number + - name: Verify Pull Request Creation + if: env.branch_exists == 'false' run: | - pr_number=$(gh pr list --state open --head ${{ env.branch_name }} --json number -q '.[0].number') - echo "pr_number=$pr_number" >> $GITHUB_ENV - echo "PR number: $pr_number" + pr_url=$(gh pr list --state open --head ${{ env.branch_name }} --json url -q '.[0].url') + echo "PR URL: $pr_url" + if [ -z "$pr_url" ]; then + echo "PR creation failed." + exit 1 + else + echo "PR created successfully: $pr_url" + fi - name: Append commit to existing PR if: env.branch_exists == 'true' run: | - echo "Appending commit to PR #${{ env.pr_number }}" + pr_number=$(gh pr list --state open --head ${{ env.branch_name }} --json number -q '.[0].number') + echo "pr_number=$pr_number" >> $GITHUB_ENV gh pr comment ${{ env.pr_number }} --body "New commits have been added to the PR."