play: use " in JSON data/modify PR

This commit is contained in:
Alessandro Pezzè 2020-04-23 22:31:08 +02:00
parent 016f4be874
commit 773a0429ed

View file

@ -33,7 +33,7 @@ pr_content() {
cat <<EOF cat <<EOF
{ {
"title": "API data update", "title": "API data update",
"body": 'Incoming data generated by https://github.com/PokeAPI/pokeapi CircleCI worker', "body": "Incoming data generated by https://github.com/PokeAPI/pokeapi CircleCI worker",
"head": "$branch_name", "head": "$branch_name",
"base": "master", "base": "master",
"assignees": [ "assignees": [
@ -46,6 +46,19 @@ pr_content() {
EOF EOF
} }
assignees_and_labels() {
cat <<EOF
{
"assignees": [
"Naramsim"
],
"labels": [
"api-data-update"
]
}
EOF
}
reviewers() { reviewers() {
cat <<EOF cat <<EOF
{ {
@ -58,7 +71,12 @@ EOF
create_pr() { create_pr() {
pr_number=$(curl -H "Authorization: token $MACHINE_USER_GITHUB_API_TOKEN" -X POST --data "$(pr_content)" "https://api.github.com/repos/$org/$data_repo/pulls" | jq '.number') pr_number=$(curl -H "Authorization: token $MACHINE_USER_GITHUB_API_TOKEN" -X POST --data "$(pr_content)" "https://api.github.com/repos/$org/$data_repo/pulls" | jq '.number')
echo pr_number echo "$pr_number"
}
customize_pr() {
pr_number=$1
curl -H "Authorization: token $MACHINE_USER_GITHUB_API_TOKEN" -X PATCH --data "$(assignees_and_labels)" "https://api.github.com/repos/$org/$data_repo/issues/$pr_number"
} }
assign_pr() { assign_pr() {
@ -73,4 +91,6 @@ push
sleep 10 sleep 10
pr_number=$(create_pr) pr_number=$(create_pr)
sleep 10 sleep 10
customize_pr "$pr_number"
sleep 10
assign_pr "$pr_number" assign_pr "$pr_number"