0

I'm trying to set a dynamic Appflow channel name in package.json

"cordova-plugin-ionic": {
        "APP_ID": "********",
        "CHANNEL_NAME": "./branch.sh",
        "UPDATE_METHOD": "auto",
        "MAX_STORE": "2",
        "MIN_BACKGROUND_DURATION": "30",
        "UPDATE_API": "https://api.ionicjs.com"
      },

branch.sh handles the channel name like this

if [ "$CI_GIT_REF" = "develop" ]; then
    Develop
fi

if [ "$CI_GIT_REF" = "master" ]; then
    Master
fi

I've searched far and wide across the internet but no luck.

1 Answers1

0

The correct way is to use "preinstall" script in package.json which updates the file. changing the branch.sh file to be:

#!/bin/bash
if [ "$CI_GIT_REF" = "master" ]; then
    sed -i "s/BRANCH_NAME/Master/g" package.json
else
    sed -i "s/BRANCH_NAME/Develop/g" package.json
fi

I'm sure there is a more dynamic way of doing this to manage many dynamic channels but my .sh knowledge is limited and I'm just happy to find a solution.