forgejo: fix authorization issues

This commit is contained in:
Antoine Martin 2025-02-18 12:09:11 -05:00
parent 8963a82eaa
commit 602730b1d2
Signed by: ayakael
GPG key ID: D62A472A4AA7D541

View file

@ -18,9 +18,8 @@ does_it_exist() {
query="$(echo $query | sed 's| |%20|g' | sed 's|:|%3A|g' | sed 's|/|%2F|g' )" query="$(echo $query | sed 's| |%20|g' | sed 's|:|%3A|g' | sed 's|/|%2F|g' )"
result="$(curl --silent -X 'GET' \ result="$(curl --silent -X 'GET' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues&token=$ISSUE_TOKEN" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN"
)" )"
if [ "$result" == "[]" ]; then if [ "$result" == "[]" ]; then
@ -40,7 +39,7 @@ is_it_old() {
result="$(curl --silent -X 'GET' \ result="$(curl --silent -X 'GET' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" -H "authorization: $ISSUE_TOKEN"
)" )"
result_title="$(echo $result | jq -r '.[].title' )" result_title="$(echo $result | jq -r '.[].title' )"
@ -64,7 +63,7 @@ update_title() {
result=$(curl --silent -X 'PATCH' \ result=$(curl --silent -X 'PATCH' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues/$id" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues/$id" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" \ -H "authorization: $ISSUE_TOKEN" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d "{ -d "{
\"title\": \"$repo/$name: upgrade to $upstream_version\" \"title\": \"$repo/$name: upgrade to $upstream_version\"
@ -83,7 +82,7 @@ create_issue() {
result=$(curl --silent -X 'POST' \ result=$(curl --silent -X 'POST' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" \ -H "authorization: $ISSUE_TOKEN" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d "{ -d "{
\"title\": \"$repo/$name: upgrade to $upstream_version\", \"title\": \"$repo/$name: upgrade to $upstream_version\",
@ -131,7 +130,7 @@ if [ -f not_in_anitya ]; then
result="$(curl --silent -X 'GET' \ result="$(curl --silent -X 'GET' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues?state=open&q=$query&type=issues" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" -H "authorization: $ISSUE_TOKEN"
)" )"
if [ "$result" == "[]" ]; then if [ "$result" == "[]" ]; then
@ -139,7 +138,7 @@ if [ -f not_in_anitya ]; then
result=$(curl --silent -X 'POST' \ result=$(curl --silent -X 'POST' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" \ -H "authorization: $ISSUE_TOKEN" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d "{ -d "{
\"title\": \"Add missing $repo packages to anitya\", \"title\": \"Add missing $repo packages to anitya\",
@ -155,7 +154,7 @@ if [ -f not_in_anitya ]; then
result=$(curl --silent -X 'PATCH' \ result=$(curl --silent -X 'PATCH' \
"$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues/$result_id" \ "$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/issues/$result_id" \
-H 'accept: application/json' \ -H 'accept: application/json' \
-H "authorization: Basic $ISSUE_TOKEN" \ -H "authorization: $ISSUE_TOKEN" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d "{ -d "{
\"body\": \"- [ ] $(sed '{:q;N;s/\n/\\n- [ ] /g;t q}' not_in_anitya)\" \"body\": \"- [ ] $(sed '{:q;N;s/\n/\\n- [ ] /g;t q}' not_in_anitya)\"