diff --git a/actions/balance-filter/deploy.sh b/actions/balance-filter/deploy.sh index bfbeff05..d61dab73 100755 --- a/actions/balance-filter/deploy.sh +++ b/actions/balance-filter/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \ --auth "$openwhiskApiKey" --param push_notification_trigger "send-push-notification" --param db_url "http://admin:p@ssw0rd@172.17.0.1:5984" --param db_name "balance_filter_db" -a provide-api-key true - -clear_temp \ No newline at end of file diff --git a/actions/balance-notification-registration/deploy.sh b/actions/balance-notification-registration/deploy.sh index 26a48e7b..ea62e730 100755 --- a/actions/balance-notification-registration/deploy.sh +++ b/actions/balance-notification-registration/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \ --auth "$openwhiskApiKey" --param event_registration_db "event_registration_db" --param balance_filter_db "balance_filter_db" --param db_name "balance_notification_registration_db" --param db_url "http://admin:p@ssw0rd@172.17.0.1:5984" --web true - -clear_temp \ No newline at end of file diff --git a/actions/event-receiver/deploy.sh b/actions/event-receiver/deploy.sh index 62f2bb1f..00d10818 100755 --- a/actions/event-receiver/deploy.sh +++ b/actions/event-receiver/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \ --auth "$openwhiskApiKey" -a provide-api-key true - -clear_temp \ No newline at end of file diff --git a/actions/event-registration/deploy.sh b/actions/event-registration/deploy.sh index e351c661..e4cd3744 100755 --- a/actions/event-registration/deploy.sh +++ b/actions/event-registration/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --docker "$DOCKER_IMAGE" \ --auth "$openwhiskApiKey" --param db_name "event_registration_db" --param db_url "http://admin:p@ssw0rd@172.17.0.1:5984" --param feed "kafka-provider-feed" --param brokers "[\"172.17.0.1:9092\"]" -a provide-api-key true - -clear_temp \ No newline at end of file diff --git a/actions/kafka-provider-feed/deploy.sh b/actions/kafka-provider-feed/deploy.sh index a423bbf5..3fc63012 100755 --- a/actions/kafka-provider-feed/deploy.sh +++ b/actions/kafka-provider-feed/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --kind nodejs:default \ --auth "$openwhiskApiKey" -a feed true --param endpoint "http://172.17.0.1:8888" --param web_action "kafka-provider-web" -a provide-api-key true - -clear_temp \ No newline at end of file diff --git a/actions/kafka-provider-web/deploy.sh b/actions/kafka-provider-web/deploy.sh index d1cb2317..a6be0e76 100755 --- a/actions/kafka-provider-web/deploy.sh +++ b/actions/kafka-provider-web/deploy.sh @@ -24,5 +24,3 @@ build $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/main.zip" --kind nodejs:default \ --auth "$openwhiskApiKey" --param endpoint "http://172.17.0.1:8888" --param db_url "http://admin:p@ssw0rd@172.17.0.1:5984" --param db_name "ow_kafka_triggers" -a provide-api-key true --web true - -clear_temp \ No newline at end of file diff --git a/actions/push-notification/deploy.sh b/actions/push-notification/deploy.sh index 36e6963e..37a6014c 100755 --- a/actions/push-notification/deploy.sh +++ b/actions/push-notification/deploy.sh @@ -28,5 +28,3 @@ $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/mai $WSK_CLI -i --apihost "$openwhiskApiHost" trigger update "send-${ACTION}" --auth "$openwhiskApiKey" $WSK_CLI -i --apihost "$openwhiskApiHost" rule update "${ACTION}-rule" "send-${ACTION}" ${ACTION} --auth "$openwhiskApiKey" - -clear_temp \ No newline at end of file diff --git a/actions/substrate-event-processor/deploy.sh b/actions/substrate-event-processor/deploy.sh index 691eb9bf..ed81c0d9 100755 --- a/actions/substrate-event-processor/deploy.sh +++ b/actions/substrate-event-processor/deploy.sh @@ -27,5 +27,3 @@ $WSK_CLI -i --apihost "$openwhiskApiHost" action update ${ACTION} "$TEMP_DIR/mai $WSK_CLI -i --apihost "$openwhiskApiHost" trigger update "produce-event" --auth "$openwhiskApiKey" $WSK_CLI -i --apihost "$openwhiskApiHost" rule update "produce-event-rule" "produce-event" "event-producer" --auth "$openwhiskApiKey" - -clear_temp \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index ee18b252..8d67adb9 100755 --- a/deploy.sh +++ b/deploy.sh @@ -6,13 +6,22 @@ openwhiskApiHost=${openwhiskApiHost:-https://localhost:31001} openwhiskApiKey=${openwhiskApiKey:-23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP} openwhiskNamespace=${openwhiskNamespace:-guest} +build=${build:-push-notification,balance-filter,event-receiver,event-registration,balance-notification-registration,event-producer,kafka-provider-feed,kafka-provider-web,substrate-event-processor} +skip=${skip:-} actions=("actions/push-notification" "actions/balance-filter" "actions/event-receiver" "actions/event-registration" "actions/balance-notification-registration" "actions/event-producer" "actions/kafka-provider-feed" "actions/kafka-provider-web" "actions/substrate-event-processor") source ./scripts/accept_params.sh +source ./scripts/util.sh + +build_array=(${build//,/ }) +skip_array=(${skip//,/ }) for index in ${!actions[@]}; do - chmod +x "$PWD/${actions[$index]}/deploy.sh" - "$PWD/${actions[$index]}/deploy.sh" --openwhiskApiHost "$openwhiskApiHost" --openwhiskApiKey "$openwhiskApiKey" --openwhiskNamespace "$openwhiskNamespace" + array_contains "${actions[$index]//actions\//}" "${skip_array[@]}" && true || { + array_contains "${actions[$index]//actions\//}" "${build_array[@]}" && should_build=true || should_build=false + chmod +x "$PWD/${actions[$index]}/deploy.sh" + "$PWD/${actions[$index]}/deploy.sh" --openwhiskApiHost "$openwhiskApiHost" --openwhiskApiKey "$openwhiskApiKey" --openwhiskNamespace "$openwhiskNamespace" --build $should_build + } done diff --git a/docs/configuration.md b/docs/configuration.md index 412edfa6..36ed153e 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -48,3 +48,32 @@ Organization space where the actions to be deployed ./deploy.sh --openwhiskNamespace guest ``` +### + +### Build Action + +Provide actions to be build, Accepts `none` or name of the actions separated by `,` to be build + +| Parameter | Default Value | +| :--- | :--- | +| --build | push-notification,balance-filter,event-receiver,event-registration,balance-notification-registration,event-producer,kafka-provider-feed,kafka-provider-web,substrate-event-processor | + +#### usage + +```text +./deploy.sh --build push-notification +``` + +### Skip Build and Deploy Action + +Provide actions to be skip, Accepts name of the available actions separated by `,` + +| Parameter | Default Value | +| :--- | :--- | +| --skip | none | + +#### usage + +```text +./deploy.sh --skip push-notification,balance-filter +``` \ No newline at end of file diff --git a/scripts/build_js_action.sh b/scripts/build_js_action.sh index de5e472e..dd2997e6 100644 --- a/scripts/build_js_action.sh +++ b/scripts/build_js_action.sh @@ -1,16 +1,18 @@ -if [ -e $TEMP_DIR ]; then - echo "Clearing previously packed action files." - rm -rf $TEMP_DIR +if [ "$build" = true ]; then + if [ -e $TEMP_DIR ]; then + echo "Clearing previously packed action files." + rm -rf $TEMP_DIR + fi + + mkdir -p $TEMP_DIR + echo "Creating temporary directory" + + echo "Copying files to temporary directory" + cp -r "$SRC_DIR/package.json" "$SRC_DIR/lib" "$SRC_DIR/main.js" $TEMP_DIR + + cd $TEMP_DIR + + yarn install --production=true + + zip -r "$TEMP_DIR/main.zip" * fi - -mkdir -p $TEMP_DIR -echo "Creating temporary directory" - -echo "Copying files to temporary directory" -cp -r "$SRC_DIR/package.json" "$SRC_DIR/lib" "$SRC_DIR/main.js" $TEMP_DIR - -cd $TEMP_DIR - -yarn install --production=true - -zip -r "$TEMP_DIR/main.zip" * \ No newline at end of file diff --git a/scripts/build_rust_action.sh b/scripts/build_rust_action.sh index 798134c7..f14f6573 100644 --- a/scripts/build_rust_action.sh +++ b/scripts/build_rust_action.sh @@ -1,17 +1,17 @@ DOCKER_IMAGE="hugobyte/openwhisk-runtime-rust:v0.2" -if [ -e $TEMP_DIR ]; then - echo "Clearing previously packed action files." - rm -rf $TEMP_DIR +if [ "$build" = true ]; then + if [ -e $TEMP_DIR ]; then + echo "Clearing previously packed action files." + rm -rf $TEMP_DIR + fi + + mkdir -p $TEMP_DIR + echo "Creating temporary directory" + + echo "Building Source to $TEMP_DIR/main.zip" + + cd $SRC_DIR + + zip -r - Cargo.toml src | docker run -e RELEASE=true -i --rm $DOCKER_IMAGE -compile main > "$TEMP_DIR/main.zip" fi - -mkdir -p $TEMP_DIR -echo "Creating temporary directory" - -echo "Building Source to $TEMP_DIR/main.zip" - -cd $SRC_DIR - -zip -r - Cargo.toml src | docker run -e RELEASE=true -i --rm $DOCKER_IMAGE -compile main > "$TEMP_DIR/main.zip" - -cd $TEMP_DIR diff --git a/scripts/util.sh b/scripts/util.sh new file mode 100644 index 00000000..ddbeefc8 --- /dev/null +++ b/scripts/util.sh @@ -0,0 +1,11 @@ +array_contains () { + local seeking=$1; shift + local in=1 + for element; do + if [[ $element == "$seeking" ]]; then + in=0 + break + fi + done + return $in +} \ No newline at end of file