~dricottone/huttese-apk

daae12e4aeeff77e2a1d5ee7c98274f1c5e51d44 — Drew DeVault 3 years ago a38916e
submit-builds: use GraphQL
1 files changed, 21 insertions(+), 10 deletions(-)

M submit-builds
M submit-builds => submit-builds +21 -10
@@ 13,7 13,7 @@ do
			upstream="$OPTARG"
			;;
		t)
			legacy_token="$OPTARG"
			bearer_token="$OPTARG"
			;;
		h)
			echo "Usage: $0 [-u https://upstream...] [-t oauth token] <packages...>"


@@ 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 .