Files
birdcam/scripts/create_pr_gitea.sh
Andrew Kettel b746cfc555
Some checks failed
CI / install (pull_request) Failing after 1m12s
CI / black (pull_request) Has been skipped
CI / ruff (pull_request) Has been skipped
CI / mypy (pull_request) Has been skipped
CI / pytest (pull_request) Has been skipped
Adding Gitea CI/CD
2026-03-26 12:50:01 -07:00

42 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
BRANCH="dependency-updates-$(date +%Y%m%d)"
SUMMARY_FILE="/tmp/update_summary.md"
git config user.email "ci@gitea.com"
git config user.name "Gitea CI"
git checkout -b "$BRANCH"
git add pyproject.toml poetry.lock
git commit -m "chore: update dependencies $(date +%Y-%m-%d)"
git push "https://oauth2:${CI_TOKEN}@${CI_SERVER_URL#https://}/${REPO}.git" "$BRANCH"
DESCRIPTION=$(cat "$SUMMARY_FILE")
HTTP_RESPONSE=$(curl --silent --show-error \
--write-out "HTTPSTATUS:%{http_code}" \
--request POST \
--header "Authorization: token ${CI_TOKEN}" \
--header "Content-Type: application/json" \
--data "{
\"head\": \"${BRANCH}\",
\"base\": \"main\",
\"title\": \"chore: dependency updates $(date +%Y-%m-%d)\",
\"body\": $(echo "$DESCRIPTION" | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))'),
\"assignees\": [${CI_ASSIGNEE_ID}]
}" \
"${CI_SERVER_URL}/api/v1/repos/${REPO}/pulls")
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS:.*//g')
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
echo "API response status: $HTTP_STATUS"
echo "API response body: $HTTP_BODY"
if [ "$HTTP_STATUS" -ne 201 ]; then
echo "Failed to create pull request"
exit 1
fi
echo "Pull request created for branch: $BRANCH"