diff --git a/action.yaml b/action.yaml index e69de29..36db4dc 100644 --- a/action.yaml +++ b/action.yaml @@ -0,0 +1,28 @@ +name: 'Edge Connect Deploy' +description: 'Deploys an Edge Connect application using the edge-connect-client' +author: 'DevFW' + +inputs: + config-file: + description: 'Path to the Edge Connect configuration file.' + required: true + dry-run: + description: 'Perform a dry run of the deployment.' + required: false + default: 'false' + version: + description: 'The version of the edge-connect-client to use.' + required: false + default: 'v0.1.0' + +runs: + using: 'composite' + steps: + - name: 'Download and run edge-connect-client' + run: | + ${{ github.action_path }}/endpoint.sh + shell: bash + env: + INPUT_CONFIG-FILE: ${{ inputs.config-file }} + INPUT_DRY-RUN: ${{ inputs.dry-run }} + INPUT_VERSION: ${{ inputs.version }} diff --git a/endpoint.sh b/endpoint.sh index febba30..4f8500c 100644 --- a/endpoint.sh +++ b/endpoint.sh @@ -1,3 +1,28 @@ #!/bin/bash set -euo pipefail +main() { + local download_url="https://edp.buildth.ing/DevFW-CICD/edge-connect-client/releases/download/${INPUT_VERSION}/edge-connect-client_Linux_x86_64.tar.gz" + + echo "Downloading edge-connect-client from ${download_url}" + + local temp_dir + temp_dir=$(mktemp -d) + + curl -sSL "${download_url}" | tar -xz -C "${temp_dir}" + + local cli_path="${temp_dir}/edge-connect-client" + chmod +x "${cli_path}" + + local -a args + args=("--file" "${INPUT_CONFIG-FILE}") + + if [[ "${INPUT_DRY-RUN}" == "true" ]]; then + args+=("--dry-run") + fi + + # The CLI uses an interactive prompt, so we need to pipe "yes" to it. + yes | "${cli_path}" apply "${args[@]}" +} + +main \ No newline at end of file