19 lines
781 B
Bash
19 lines
781 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
## requirements: httpie
|
||
|
|
||
|
set -eo pipefail
|
||
|
|
||
|
GITEA_SERVER=https://gitea.example.com
|
||
|
GITEA_TOKEN=my-private-token
|
||
|
GITEA_USER="gitea"
|
||
|
GITEA_PR_TITLE=
|
||
|
|
||
|
http "https://${GITEA_SERVER}/api/v1/user" 'Authorization:token '"${GITEA_TOKEN}"''
|
||
|
|
||
|
for repo in $(http -b "https://${GITEA_SERVER}/api/v1/users/${GITEA_USER}/repos" 'Authorization:token '"${GITEA_TOKEN}"'' | jq -r '.[] | .full_name'); do
|
||
|
for pr_number in $(http -b "https://${GITEA_SERVER}/api/v1/repos/${repo}/pulls" 'Authorization:token '"${GITEA_TOKEN}"'' state==open | jq -r '.[] | select(.title | contains("'"${GITEA_PR_TITLE}"'")) | .number'); do
|
||
|
http POST "https://${GITEA_SERVER}/api/v1/repos/${repo}/pulls/${pr_number}/merge" 'Authorization:token '"${GITEA_TOKEN}"'' do=squash
|
||
|
done
|
||
|
done
|