This repository has been archived by the owner on Mar 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from CatalystCode/create-site
Call GraphQL createSite during deployment
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
readonly graphql_service_host="$1" | ||
readonly site_name="$2" | ||
readonly site_type="$3" | ||
|
||
if ! (command -v python >/dev/null); then sudo apt-get install -y python; fi | ||
|
||
cat << EOF | python | curl "${graphql_service_host}/api/settings" -d@- -H "Content-Type: application/json" | ||
# | ||
# parameters included from bash via variable interpolation | ||
# | ||
siteType = '${site_type}' | ||
name = '${site_name}' | ||
# | ||
# python script to format graphql json request body | ||
# | ||
import json | ||
import sys | ||
query = '''mutation { | ||
createSite( | ||
input: { | ||
siteType: "%s", | ||
targetBbox: [], | ||
defaultZoomLevel: 0, | ||
logo: "", | ||
title: "", | ||
name: "%s", | ||
defaultLocation: [], | ||
storageConnectionString: "", | ||
mapzenApiKey: "", | ||
fbToken: "", | ||
supportedLanguages: [] | ||
} | ||
) { name } | ||
}''' % ( | ||
siteType, | ||
name, | ||
) | ||
payload = { | ||
'query': query, | ||
} | ||
print(json.dumps(payload)) | ||
EOF |