erickvneri deploying to production channel #4
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
name: "SmartThings Edge Production Deployment" | |
run-name: "${{ github.actor }} deploying to production channel" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy-production: | |
runs-on: "ubuntu-latest" | |
steps: | |
- name: "Checkout Code" | |
uses: "actions/checkout@v3" | |
- name: "SmartThings CLI" | |
uses: "actions/setup-node@v2" | |
- run: "npm install --global @smartthings/cli" | |
- name: "Upgrade Edge Drivers" | |
uses: "actions/checkout@v3" | |
- run: | | |
DRIVERS_PATH=${{ github.workspace }}/zigbee; | |
TARGET_CHANNEL=${{ secrets.ST_CHANNEL_PRODUCTION }}; | |
TOKEN=${{ secrets.ST_PAT }}; | |
deploy () { | |
DRIVER_FOLDER=$1; | |
pushd "$DRIVERS_PATH/$DRIVER_FOLDER"; | |
DRIVER_UUID=$( | |
smartthings edge:drivers:package --json --token $TOKEN | \ | |
jq .driverId | \ | |
tr -d '"' | |
); | |
echo "driver $DRIVER_FOLDER$DRIVER_UUID packaged correctly"; | |
smartthings edge:channels:assign "$DRIVER_UUID" \ | |
--channel $TARGET_CHANNEL \ | |
--token $TOKEN \ | |
&& echo "driver $DRIVER_FOLDER$DRIVER_UUID released correctly"; | |
popd; | |
} | |
cd $DRIVERS_PATH; | |
for DRIVER_DIR in $(ls -d */); do | |
deploy $DRIVER_DIR | |
done |