From daae12e4aeeff77e2a1d5ee7c98274f1c5e51d44 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 26 Aug 2021 08:53:48 +0200 Subject: [PATCH] submit-builds: use GraphQL --- submit-builds | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/submit-builds b/submit-builds index 57fcfdd..c5f7b68 100755 --- a/submit-builds +++ b/submit-builds @@ -13,7 +13,7 @@ do upstream="$OPTARG" ;; t) - legacy_token="$OPTARG" + bearer_token="$OPTARG" ;; h) echo "Usage: $0 [-u https://upstream...] [-t oauth token] " @@ -39,13 +39,24 @@ do fi fi done -sed "s/packages: \\[\\]/packages: [$builds]/g" < build.yml | jq -sR '{ - "manifest": ., - "tags": ["sr.ht-apkbuilds"], - "note": "'"$note"'" - }' | curl \ - -H Authorization:"token $legacy_token" \ + +vars="$(sed "s/packages: \\[\\]/packages: [$builds]/g" < build.yml | jq -sR '{ + "manifest": ., + "tags": ["sr.ht-apkbuilds"], + "note": "'"$note"'" +}')" +query="$(jq -sR '.' <<"EOF" +mutation SubmitJob($manifest: String!, $tags: [String!]!, $note: String!) { + submit(manifest: $manifest, tags: $tags, note: $note) { + id, tags + } +} +EOF +)" + +curl --oauth2-bearer "$bearer_token" \ -H Content-Type:application/json \ - -X POST \ - -d @- $upstream/api/jobs -printf '\n' + -d '{ + "query": '"$query"', + "variables": '"$vars"' + }' "$upstream/query" | jq . -- 2.45.2