build-deploy-app.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. set -o errexit
  3. set -o nounset
  4. set -o pipefail
  5. # shellcheck disable=SC1091
  6. source hack/get-tools.sh
  7. plantbuild push ./plantbuild/build.jsonnet
  8. # https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#create-a-repository-dispatch-event
  9. build_json=$(plantbuild show ./plantbuild/build.jsonnet | jq -r .services)
  10. output_json='{"event_type": "deploy-test"}'
  11. for key in $(echo "$build_json" | jq -r keys[]); do
  12. app_name=$(echo "$key" | sed 's/build_image_//')
  13. image=$( echo "$build_json" | jq -r --arg key "$key" '.[$key].image')
  14. output_json=$(echo "$output_json" | jq -r \
  15. --arg app_name "$app_name" \
  16. --arg image "$image" \
  17. '.client_payload.github[$app_name].image = $image')
  18. done
  19. echo $output_json | jq .
  20. curl -XPOST -H "Content-Type: application/json" \
  21. -H "Accept: application/vnd.github.everest-preview+json" \
  22. -H "Authorization: Bearer $GITHUB_TOKEN" \
  23. https://api.github.com/repos/theplant/qor5-provisioning/dispatches \
  24. -d @- <<EOF
  25. $output_json
  26. EOF