Fix update-clan-core-for-checks script
create-pr needs to use /bin/sh to work. This PR makes the script posix compliant, replacing any bash specific features with plain sh alternatives
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Shared script for creating pull requests in Gitea workflows
|
# Shared script for creating pull requests in Gitea workflows
|
||||||
set -euo pipefail
|
set -eu
|
||||||
|
|
||||||
# Required environment variables:
|
# Required environment variables:
|
||||||
# - CI_BOT_TOKEN: Gitea bot token for authentication
|
# - CI_BOT_TOKEN: Gitea bot token for authentication
|
||||||
@@ -8,22 +9,22 @@ set -euo pipefail
|
|||||||
# - PR_TITLE: Title of the pull request
|
# - PR_TITLE: Title of the pull request
|
||||||
# - PR_BODY: Body/description of the pull request
|
# - PR_BODY: Body/description of the pull request
|
||||||
|
|
||||||
if [[ -z "${CI_BOT_TOKEN:-}" ]]; then
|
if [ -z "${CI_BOT_TOKEN:-}" ]; then
|
||||||
echo "Error: CI_BOT_TOKEN is not set" >&2
|
echo "Error: CI_BOT_TOKEN is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${PR_BRANCH:-}" ]]; then
|
if [ -z "${PR_BRANCH:-}" ]; then
|
||||||
echo "Error: PR_BRANCH is not set" >&2
|
echo "Error: PR_BRANCH is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${PR_TITLE:-}" ]]; then
|
if [ -z "${PR_TITLE:-}" ]; then
|
||||||
echo "Error: PR_TITLE is not set" >&2
|
echo "Error: PR_TITLE is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "${PR_BODY:-}" ]]; then
|
if [ -z "${PR_BODY:-}" ]; then
|
||||||
echo "Error: PR_BODY is not set" >&2
|
echo "Error: PR_BODY is not set" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -43,9 +44,12 @@ resp=$(nix run --inputs-from . nixpkgs#curl -- -X POST \
|
|||||||
}" \
|
}" \
|
||||||
"https://git.clan.lol/api/v1/repos/clan/clan-core/pulls")
|
"https://git.clan.lol/api/v1/repos/clan/clan-core/pulls")
|
||||||
|
|
||||||
pr_number=$(echo "$resp" | jq -r '.number')
|
if ! pr_number=$(echo "$resp" | jq -r '.number'); then
|
||||||
|
echo "Error parsing response from pull request creation" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$pr_number" == "null" ]]; then
|
if [ "$pr_number" = "null" ]; then
|
||||||
echo "Error creating pull request:" >&2
|
echo "Error creating pull request:" >&2
|
||||||
echo "$resp" | jq . >&2
|
echo "$resp" | jq . >&2
|
||||||
exit 1
|
exit 1
|
||||||
@@ -64,12 +68,15 @@ while true; do
|
|||||||
"delete_branch_after_merge": true
|
"delete_branch_after_merge": true
|
||||||
}' \
|
}' \
|
||||||
"https://git.clan.lol/api/v1/repos/clan/clan-core/pulls/$pr_number/merge")
|
"https://git.clan.lol/api/v1/repos/clan/clan-core/pulls/$pr_number/merge")
|
||||||
msg=$(echo "$resp" | jq -r '.message')
|
if ! msg=$(echo "$resp" | jq -r '.message'); then
|
||||||
if [[ "$msg" != "Please try again later" ]]; then
|
echo "Error parsing merge response" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$msg" != "Please try again later" ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo "Retrying in 2 seconds..."
|
echo "Retrying in 2 seconds..."
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Pull request #$pr_number merge initiated"
|
echo "Pull request #$pr_number merge initiated"
|
||||||
|
|||||||
Reference in New Issue
Block a user