42 lines
1.3 KiB
Bash
Executable File
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" |