diff --git a/.github/workflows/update-flake.yml b/.github/workflows/update-flake.yml index 806e2111..d37790d6 100644 --- a/.github/workflows/update-flake.yml +++ b/.github/workflows/update-flake.yml @@ -75,15 +75,32 @@ jobs: GH_TOKEN: ${{ steps.generate-token.outputs.token }} base_branch: ${{ matrix.branch }} body: "This is an automated update triggered by the [workflow run #${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." # yamllint disable-line rule:line-length + label: "topic: dependencies" pr_branch: update_flake_lock_action_${{ matrix.branch }} title: "${{ startsWith(matrix.branch, 'release') && format('[{0}] ', matrix.branch) || '' }}flake: update public and dev inputs" # yamllint disable-line rule:line-length run: | git switch --create "$pr_branch" git push origin "$pr_branch" --force --set-upstream - gh pr create \ - --base "$base_branch" \ - --body "$body" \ - --label "topic: dependencies" \ - --title "$title" || - echo "Failed to create PR" + pr_count="$( + gh api \ + --method GET \ + "/repos/$GITHUB_REPOSITORY/pulls" \ + --field per_page=1 \ + --raw-field head="$GITHUB_REPOSITORY_OWNER:$pr_branch" \ + --jq length + )" + + if ((pr_count)); then + gh pr edit \ + --body "$body" \ + --label "$label" \ + --title "$title" + + else + gh pr create \ + --base "$base_branch" \ + --body "$body" \ + --label "$label" \ + --title "$title" + fi