2023-08-17 08:31:47 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
## requirements: httpie
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
2023-08-17 08:53:11 +00:00
|
|
|
GITEA_SERVER="${GITEA_SERVER:-https://gitea.example.com}"
|
|
|
|
GITEA_TOKEN="${GITEA_TOKEN:-my-private-token}"
|
|
|
|
GITEA_USER="${GITEA_USER:-gitea}"
|
|
|
|
GITEA_PR_TITLE="${GITEA_PR_TITLE:-}"
|
2023-08-17 08:31:47 +00:00
|
|
|
|
2023-08-17 08:49:31 +00:00
|
|
|
http "${GITEA_SERVER}/api/v1/user" 'Authorization:token '"${GITEA_TOKEN}"''
|
2023-08-17 08:31:47 +00:00
|
|
|
|
2023-08-17 08:49:31 +00:00
|
|
|
for repo in $(http -b "${GITEA_SERVER}/api/v1/users/${GITEA_USER}/repos" 'Authorization:token '"${GITEA_TOKEN}"'' | jq -r '.[] | .full_name'); do
|
|
|
|
for pr_number in $(http -b "${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 "${GITEA_SERVER}/api/v1/repos/${repo}/pulls/${pr_number}/merge" 'Authorization:token '"${GITEA_TOKEN}"'' do=squash
|
2023-08-17 08:31:47 +00:00
|
|
|
done
|
|
|
|
done
|