Skip to content

Commit

Permalink
Merge pull request #16 from feature/improve-deploy-script-build-process
Browse files Browse the repository at this point in the history
[Feature] Add Build and Skip params for deploy script
  • Loading branch information
MuhammedIrfan authored Sep 26, 2021
2 parents 0c7ee00 + 46893c7 commit 517e082
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 47 deletions.
2 changes: 0 additions & 2 deletions actions/balance-filter/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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@[email protected]:5984" --param db_name "balance_filter_db" -a provide-api-key true

clear_temp
2 changes: 0 additions & 2 deletions actions/balance-notification-registration/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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@[email protected]:5984" --web true

clear_temp
2 changes: 0 additions & 2 deletions actions/event-receiver/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions actions/event-registration/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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@[email protected]:5984" --param feed "kafka-provider-feed" --param brokers "[\"172.17.0.1:9092\"]" -a provide-api-key true

clear_temp
2 changes: 0 additions & 2 deletions actions/kafka-provider-feed/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions actions/kafka-provider-web/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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@[email protected]:5984" --param db_name "ow_kafka_triggers" -a provide-api-key true --web true

clear_temp
2 changes: 0 additions & 2 deletions actions/push-notification/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions actions/substrate-event-processor/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 11 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 29 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
32 changes: 17 additions & 15 deletions scripts/build_js_action.sh
Original file line number Diff line number Diff line change
@@ -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" *
28 changes: 14 additions & 14 deletions scripts/build_rust_action.sh
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions scripts/util.sh
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 517e082

Please sign in to comment.