ci: don't create multiple lockfile PRs
This commit is contained in:
parent
9699536879
commit
ae03ce2c7a
1 changed files with 18 additions and 11 deletions
29
.github/workflows/update-lock.yml
vendored
29
.github/workflows/update-lock.yml
vendored
|
@ -11,6 +11,13 @@ jobs:
|
||||||
name: Run update
|
name: Run update
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
PR_BRANCH: "update-lockfiles"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
@ -25,11 +32,7 @@ jobs:
|
||||||
- name: Create new branch
|
- name: Create new branch
|
||||||
id: branch
|
id: branch
|
||||||
run: |
|
run: |
|
||||||
# try not to conflict with other branches
|
git switch -c "$PR_BRANCH"
|
||||||
branch="update-lock/${{ github.run_id }}"
|
|
||||||
|
|
||||||
echo "branch=$branch" >> "$GITHUB_OUTPUT"
|
|
||||||
git switch -c "$branch"
|
|
||||||
|
|
||||||
- name: Update flake inputs
|
- name: Update flake inputs
|
||||||
run: |
|
run: |
|
||||||
|
@ -54,11 +57,15 @@ jobs:
|
||||||
GH_TOKEN: ${{ github.token }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
run: |
|
run: |
|
||||||
if ! git diff --color=always --exit-code origin/main; then
|
if ! git diff --color=always --exit-code origin/main; then
|
||||||
git push -u origin ${{ steps.branch.outputs.branch }}
|
git fetch origin foo || true
|
||||||
|
git push --force-with-lease -u origin "$PR_BRANCH"
|
||||||
|
|
||||||
gh pr create \
|
open_prs="$(gh pr list --base main --head "$PR_BRANCH" | wc -l)"
|
||||||
--base main \
|
if [ "$open_prs" -eq 0 ]; then
|
||||||
--head "${{ steps.branch.outputs.branch }}" \
|
gh pr create \
|
||||||
--title "chore: update lockfiles" \
|
--base main \
|
||||||
--fill
|
--head "$PR_BRANCH" \
|
||||||
|
--title "chore: update lockfiles" \
|
||||||
|
--fill
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue