55 branches :
66 - main
77 - test/**
8- workflow_dispatch :
9- inputs :
10- branch_type :
11- description : " Deploy to which environment"
12- required : true
13- type : choice
14- options :
15- - main
16- - test
17- default : " main"
188
199jobs :
2010 deploy :
3323
3424 - name : Install SmartThings CLI
3525 run : |
36- npm install -g @smartthings/cli@latest
26+ npm install --global @smartthings/cli@latest
3727
3828 - name : Setup dependencies
3929 run : |
@@ -77,27 +67,27 @@ jobs:
7767 PROFILE_NAME=$(basename "$file" .yml)
7868 echo "Processing profile: $PROFILE_NAME"
7969
80- PROFILE_ID=$(npx -y @ smartthings/cli deviceprofiles --json 2>/dev/null | jq -r '.[] | select(.name=="'"$PROFILE_NAME"'") | .id' 2>/dev/null || echo "")
70+ PROFILE_ID=$(smartthings deviceprofiles --json 2>/dev/null | jq -r '.[] | select(.name=="'"$PROFILE_NAME"'") | .id' 2>/dev/null || echo "")
8171
8272 if [[ -n "$PROFILE_ID" && "$PROFILE_ID" != "null" ]]; then
8373 echo "Deleting existing profile: $PROFILE_NAME ($PROFILE_ID)"
84- npx -y @ smartthings/cli deviceprofiles:delete "$PROFILE_ID" >/dev/null 2>&1 || true
74+ smartthings deviceprofiles:delete "$PROFILE_ID" >/dev/null 2>&1 || true
8575 fi
8676
8777 echo "Creating profile from file: $file"
88- if ! npx -y @ smartthings/cli deviceprofiles:create --input "$file" 2>&1; then
78+ if ! smartthings deviceprofiles:create --input "$file" 2>&1; then
8979 echo "ERROR: Failed to create profile $PROFILE_NAME"
9080 continue
9181 fi
9282
93- NEW_ID=$(npx -y @ smartthings/cli deviceprofiles --json 2>/dev/null | jq -r '.[] | select(.name=="'"$PROFILE_NAME"'") | .id' 2>/dev/null || echo "")
83+ NEW_ID=$(smartthings deviceprofiles --json 2>/dev/null | jq -r '.[] | select(.name=="'"$PROFILE_NAME"'") | .id' 2>/dev/null || echo "")
9484 if [[ -z "$NEW_ID" || "$NEW_ID" == "null" ]]; then
9585 echo "ERROR: Failed to find created profile $PROFILE_NAME"
9686 continue
9787 fi
9888
9989 echo "Publishing profile: $PROFILE_NAME ($NEW_ID)"
100- if ! npx -y @ smartthings/cli deviceprofiles:publish "$NEW_ID" 2>&1; then
90+ if ! smartthings deviceprofiles:publish "$NEW_ID" 2>&1; then
10191 echo "ERROR: Failed to publish profile $PROFILE_NAME"
10292 continue
10393 fi
@@ -107,52 +97,27 @@ jobs:
10797 - name : Determine channel ID
10898 id : channel
10999 run : |
110- # workflow_dispatch로 수동 실행된 경우 입력값 사용, push 이벤트인 경우 브랜치 이름 사용
111- if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
112- BRANCH_TYPE="${{ github.event.inputs.branch_type }}"
113- echo "Manual workflow dispatch with branch_type: $BRANCH_TYPE"
114-
115- if [[ "$BRANCH_TYPE" == "main" ]]; then
116- CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_MAIN }}"
117- if [[ -z "$CHANNEL_ID" ]]; then
118- echo "ERROR: SMARTTHINGS_CHANNEL_ID_MAIN secret is not set"
119- exit 1
120- fi
121- echo "Using main channel: $CHANNEL_ID"
122- elif [[ "$BRANCH_TYPE" == "test" ]]; then
123- CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_TEST }}"
124- if [[ -z "$CHANNEL_ID" ]]; then
125- echo "ERROR: SMARTTHINGS_CHANNEL_ID_TEST secret is not set"
126- exit 1
127- fi
128- echo "Using test channel: $CHANNEL_ID"
129- else
130- echo "ERROR: Unknown branch_type: $BRANCH_TYPE"
100+ BRANCH_NAME="${{ github.ref_name }}"
101+ echo "Automatic push event on branch: $BRANCH_NAME"
102+
103+ if [[ "$BRANCH_NAME" == "main" ]]; then
104+ CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_MAIN }}"
105+ if [[ -z "$CHANNEL_ID" ]]; then
106+ echo "ERROR: SMARTTHINGS_CHANNEL_ID_MAIN secret is not set"
131107 exit 1
132108 fi
133- else
134- BRANCH_NAME="${{ github.ref_name }}"
135- echo "Automatic push event on branch: $BRANCH_NAME"
136-
137- if [[ "$BRANCH_NAME" == "main" ]]; then
138- CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_MAIN }}"
139- if [[ -z "$CHANNEL_ID" ]]; then
140- echo "ERROR: SMARTTHINGS_CHANNEL_ID_MAIN secret is not set"
141- exit 1
142- fi
143- echo "Using main channel: $CHANNEL_ID"
144- elif [[ "$BRANCH_NAME" =~ ^test/ ]]; then
145- CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_TEST }}"
146- if [[ -z "$CHANNEL_ID" ]]; then
147- echo "ERROR: SMARTTHINGS_CHANNEL_ID_TEST secret is not set"
148- exit 1
149- fi
150- echo "Using test channel: $CHANNEL_ID"
151- else
152- echo "ERROR: Unknown branch pattern: $BRANCH_NAME"
153- echo "Expected branch: main or test/*"
109+ echo "Using main channel: $CHANNEL_ID"
110+ elif [[ "$BRANCH_NAME" =~ ^test/ ]]; then
111+ CHANNEL_ID="${{ secrets.SMARTTHINGS_CHANNEL_ID_TEST }}"
112+ if [[ -z "$CHANNEL_ID" ]]; then
113+ echo "ERROR: SMARTTHINGS_CHANNEL_ID_TEST secret is not set"
154114 exit 1
155115 fi
116+ echo "Using test channel: $CHANNEL_ID"
117+ else
118+ echo "ERROR: Unknown branch pattern: $BRANCH_NAME"
119+ echo "Expected branch: main or test/*"
120+ exit 1
156121 fi
157122
158123 echo "channel_id=$CHANNEL_ID" >> $GITHUB_OUTPUT
@@ -169,7 +134,7 @@ jobs:
169134
170135 # Package driver
171136 echo "Packaging driver in $folder..."
172- if ! npx -y @ smartthings/cli edge:drivers:package "$folder" 2>&1; then
137+ if ! smartthings edge:drivers:package "$folder" 2>&1; then
173138 echo "ERROR: Failed to package driver $folder"
174139 continue
175140 fi
@@ -181,7 +146,7 @@ jobs:
181146 echo "Looking for driver with packageKey: $PACKAGE_KEY or name: $DRIVER_NAME"
182147
183148 # Find driver ID by packageKey or name
184- DRIVER_ID=$(npx -y @ smartthings/cli edge:drivers --json 2>/dev/null | jq -r --arg pk "$PACKAGE_KEY" --arg name "$DRIVER_NAME" '.[] | select(.packageKey == $pk or .name == $name) | .driverId' 2>/dev/null | head -n1)
149+ DRIVER_ID=$(smartthings edge:drivers --json 2>/dev/null | jq -r --arg pk "$PACKAGE_KEY" --arg name "$DRIVER_NAME" '.[] | select(.packageKey == $pk or .name == $name) | .driverId' 2>/dev/null | head -n1)
185150
186151 if [[ -z "$DRIVER_ID" || "$DRIVER_ID" == "null" ]]; then
187152 echo "WARNING: Driver not found in existing drivers list"
@@ -194,7 +159,7 @@ jobs:
194159
195160 # Assign driver to channel
196161 echo "Assigning driver $DRIVER_ID to channel $CHANNEL_ID..."
197- if ! npx -y @ smartthings/cli edge:channels:assign --channel "$CHANNEL_ID" "$DRIVER_ID" 2>&1; then
162+ if ! smartthings edge:channels:assign --channel "$CHANNEL_ID" "$DRIVER_ID" 2>&1; then
198163 echo "ERROR: Failed to assign driver $DRIVER_ID to channel $CHANNEL_ID"
199164 continue
200165 fi
0 commit comments