ci: update-flake: handle existing PRs and avoid silent errors
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
This commit is contained in:
parent
0ef1d62a31
commit
91075d1635
1 changed files with 23 additions and 6 deletions
29
.github/workflows/update-flake.yml
vendored
29
.github/workflows/update-flake.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue