Fix dependency bot PR creation for Gitea.
Replace peter-evans/create-pull-request with a Gitea API script that commits, pushes, and opens the deps update PR. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
abaa078471
commit
a3b9912107
@@ -11,6 +11,8 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
@@ -24,10 +26,9 @@ jobs:
|
|||||||
run: uv lock --upgrade
|
run: uv lock --upgrade
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
uses: peter-evans/create-pull-request@v6
|
env:
|
||||||
with:
|
API_URL: ${{ vars.API_URL }}
|
||||||
commit-message: "chore(deps): update dependencies [automated]"
|
REPO_OWNER: ${{ github.repository_owner }}
|
||||||
branch: "renovate/auto-deps-update"
|
REPO_NAME: ${{ github.event.repository.name }}
|
||||||
title: "chore(deps): update dependencies"
|
CI_RUNNER_TOKEN: ${{ secrets.CI_RUNNER_TOKEN }}
|
||||||
body: "This PR was created automatically to update dependencies."
|
run: scripts/ci/create-deps-update-pr.sh
|
||||||
token: ${{ secrets.CI_RUNNER_TOKEN }}
|
|
||||||
|
|||||||
Executable
+64
@@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${API_URL:?API_URL is required}"
|
||||||
|
: "${REPO_OWNER:?REPO_OWNER is required}"
|
||||||
|
: "${REPO_NAME:?REPO_NAME is required}"
|
||||||
|
: "${CI_RUNNER_TOKEN:?CI_RUNNER_TOKEN is required}"
|
||||||
|
: "${GITHUB_SERVER_URL:?GITHUB_SERVER_URL is required}"
|
||||||
|
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
|
||||||
|
|
||||||
|
BRANCH="${BRANCH:-renovate/auto-deps-update}"
|
||||||
|
BASE_BRANCH="${BASE_BRANCH:-main}"
|
||||||
|
LOCKFILE="${LOCKFILE:-uv.lock}"
|
||||||
|
|
||||||
|
if git diff --quiet "$LOCKFILE"; then
|
||||||
|
echo "No dependency updates available."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "CI Bot"
|
||||||
|
git config user.email "[email protected]"
|
||||||
|
git add "$LOCKFILE"
|
||||||
|
git commit -m "chore(deps): update dependencies [automated]"
|
||||||
|
|
||||||
|
git remote set-url origin "https://x-access-token:${CI_RUNNER_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
||||||
|
git push origin "HEAD:${BRANCH}"
|
||||||
|
|
||||||
|
if curl -s "${API_URL}/repos/${REPO_OWNER}/${REPO_NAME}/pulls?state=open" \
|
||||||
|
-H "Authorization: token ${CI_RUNNER_TOKEN}" \
|
||||||
|
| BRANCH="$BRANCH" python3 -c '
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
branch = os.environ["BRANCH"]
|
||||||
|
prs = json.load(sys.stdin)
|
||||||
|
sys.exit(0 if any(pr.get("head", {}).get("ref") == branch for pr in prs) else 1)
|
||||||
|
'; then
|
||||||
|
echo "Pull request already exists; branch push updates it."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
PAYLOAD=$(BRANCH="$BRANCH" BASE_BRANCH="$BASE_BRANCH" python3 -c '
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
print(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"title": "chore(deps): update dependencies",
|
||||||
|
"body": "This PR was created automatically to update dependencies.",
|
||||||
|
"head": os.environ["BRANCH"],
|
||||||
|
"base": os.environ["BASE_BRANCH"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
')
|
||||||
|
|
||||||
|
curl -sf -X POST "${API_URL}/repos/${REPO_OWNER}/${REPO_NAME}/pulls" \
|
||||||
|
-H "Authorization: token ${CI_RUNNER_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$PAYLOAD"
|
||||||
|
|
||||||
|
echo "Created pull request."
|
||||||
Reference in New Issue
Block a user