|
| 1 | +name: 'Deploy Intrinsic Assets' |
| 2 | +description: 'Installs and adds skills and services to a solution.' |
| 3 | + |
| 4 | +inputs: |
| 5 | + organization: |
| 6 | + description: 'The Intrinsic organization' |
| 7 | + required: true |
| 8 | + solution-id: |
| 9 | + description: 'The Intrinsic solution ID' |
| 10 | + required: true |
| 11 | + skills: |
| 12 | + description: 'Comma-separated list of skill targets' |
| 13 | + required: false |
| 14 | + services: |
| 15 | + description: 'Comma-separated list of service targets' |
| 16 | + required: false |
| 17 | + |
| 18 | +runs: |
| 19 | + using: "composite" |
| 20 | + steps: |
| 21 | + - name: Install Skills |
| 22 | + shell: bash |
| 23 | + run: | |
| 24 | + if [ -z "${{ inputs.skills }}" ]; then |
| 25 | + echo "No skills to install." |
| 26 | + exit 0 |
| 27 | + fi |
| 28 | + |
| 29 | + echo "Fetching list of currently installed sideloaded skills..." |
| 30 | + INSTALLED_SKILLS=$(inctl skill list --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}" --filter "sideloaded" 2>&1) |
| 31 | + |
| 32 | + IFS=',' read -ra SKILL_ARRAY <<< "${{ inputs.skills }}" |
| 33 | + for SKILL in "${SKILL_ARRAY[@]}"; do |
| 34 | + SKILL=$(echo "$SKILL" | xargs) # trim whitespace |
| 35 | + if [ -z "$SKILL" ]; then continue; fi |
| 36 | + |
| 37 | + echo "Processing skill: $SKILL" |
| 38 | + skill_package="${SKILL%:*}" |
| 39 | + skill_package_dir="${skill_package#//}" # Remove leading // |
| 40 | + skill_name=$(basename "$skill_package_dir") |
| 41 | + skill_target="${SKILL##*:}" |
| 42 | + |
| 43 | + if echo "$INSTALLED_SKILLS" | grep -q "com.example.${skill_name}"; then |
| 44 | + echo "Skill 'com.example.${skill_name}' is already installed. Removing..." |
| 45 | + inctl asset uninstall "com.example.${skill_name}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}" |
| 46 | + fi |
| 47 | + |
| 48 | + BUNDLE_PATH="bazel-bin/${skill_package_dir}/${skill_target}.bundle.tar" |
| 49 | + echo "Installing skill from $BUNDLE_PATH" |
| 50 | + inctl skill install "$BUNDLE_PATH" --solution "${{ inputs.solution-id }}" --org "${{ inputs.organization }}" |
| 51 | + done |
| 52 | +
|
| 53 | + - name: Install and Add Services |
| 54 | + shell: bash |
| 55 | + run: | |
| 56 | + if [ -z "${{ inputs.services }}" ]; then |
| 57 | + echo "No services to install/add." |
| 58 | + exit 0 |
| 59 | + fi |
| 60 | +
|
| 61 | + echo "Fetching list of currently installed services..." |
| 62 | + INSTALLED_SERVICES_LIST=$(inctl asset list --asset_types="service" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}") |
| 63 | + |
| 64 | + declare -a SERVICES_TARGET_NAMES |
| 65 | + |
| 66 | + echo "--- Installing Services ---" |
| 67 | + IFS=',' read -ra SERVICE_ARRAY <<< "${{ inputs.services }}" |
| 68 | + for SERVICE in "${SERVICE_ARRAY[@]}"; do |
| 69 | + SERVICE=$(echo "$SERVICE" | xargs) # trim whitespace |
| 70 | + if [ -z "$SERVICE" ]; then continue; fi |
| 71 | +
|
| 72 | + echo "Processing service: $SERVICE" |
| 73 | + service_package="${SERVICE%:*}" |
| 74 | + service_package_dir="${service_package#//}" # Strip // |
| 75 | + service_target="${SERVICE##*:}" |
| 76 | + |
| 77 | + SERVICES_TARGET_NAMES+=("$service_target") |
| 78 | + |
| 79 | + if echo "$INSTALLED_SERVICES_LIST" | grep -q "com.example.${service_target}"; then |
| 80 | + echo "Service 'com.example.${service_target}' is already installed. Deleting and uninstalling..." |
| 81 | + inctl service delete "${service_target}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}" |
| 82 | + inctl asset uninstall "com.example.${service_target}" --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}" |
| 83 | + echo "Waiting for 20 seconds..." |
| 84 | + sleep 20 |
| 85 | + fi |
| 86 | + |
| 87 | + BUNDLE_PATH="bazel-bin/${service_package_dir}/${service_target}.bundle.tar" |
| 88 | + echo "Installing service from $BUNDLE_PATH" |
| 89 | + inctl service install "$BUNDLE_PATH" --solution "${{ inputs.solution-id }}" --org "${{ inputs.organization }}" |
| 90 | + done |
| 91 | + |
| 92 | + echo "--- Adding Services ---" |
| 93 | + if [ ${#SERVICES_TARGET_NAMES[@]} -eq 0 ]; then |
| 94 | + echo "No services were installed, skipping 'add' step." |
| 95 | + exit 0 |
| 96 | + fi |
| 97 | + |
| 98 | + echo "Fetching full list of available assets to find service full names..." |
| 99 | + LATEST_ASSET_LIST=$(inctl asset list --org "${{ inputs.organization }}" --solution "${{ inputs.solution-id }}") |
| 100 | + |
| 101 | + for SERVICE_SHORT_NAME in "${SERVICES_TARGET_NAMES[@]}"; do |
| 102 | + SERVICE_FULL_NAME="" |
| 103 | + while IFS= read -r full_service_name; do |
| 104 | + if [[ "$full_service_name" == *".$SERVICE_SHORT_NAME" ]]; then |
| 105 | + SERVICE_FULL_NAME=$(echo "$full_service_name" | xargs) |
| 106 | + break |
| 107 | + fi |
| 108 | + done <<< "$LATEST_ASSET_LIST" |
| 109 | +
|
| 110 | + if [ -n "$SERVICE_FULL_NAME" ]; then |
| 111 | + echo "Adding service '$SERVICE_FULL_NAME' as '$SERVICE_SHORT_NAME'..." |
| 112 | + inctl service add "$SERVICE_FULL_NAME" \ |
| 113 | + --org "${{ inputs.organization }}" \ |
| 114 | + --solution "${{ inputs.solution-id }}" \ |
| 115 | + --name "$SERVICE_SHORT_NAME" |
| 116 | + else |
| 117 | + echo "::warning::Could not find full name for short name '$SERVICE_SHORT_NAME'. Skipping 'add'." |
| 118 | + fi |
| 119 | + done |
0 commit comments