From 2a87026785fc0021c0982725a2377158f8ff69ee Mon Sep 17 00:00:00 2001 From: Dan Blanchard Date: Wed, 28 Aug 2024 14:49:37 -0400 Subject: [PATCH] Use version-specific caches and same method for setting up args as run-action --- action.yml | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/action.yml b/action.yml index 1429e00..22bea88 100644 --- a/action.yml +++ b/action.yml @@ -30,24 +30,32 @@ runs: - uses: actions/checkout@v4 - name: Install conda environment uses: mamba-org/setup-micromamba@v1 + env: + PYTHON_VERSION: 3.12 + COILED_VERSION: 1.45.0 with: - cache-downloads-key: coiled-login-downloads-${{ runner.arch }} - cache-environment-key: coiled-login-env-${{ runner.arch }} + cache-downloads-key: coiled-login-downloads-${{ runner.arch }}-${{ envs.PYTHON_VERSION }}-${{ envs.COILED_VERSION }} + cache-environment-key: coiled-login-env-${{ runner.arch }}-${{ envs.PYTHON_VERSION }}-${{ envs.COILED_VERSION }} generate-run-shell: false environment-name: coiled-login create-args: >- - python=3.12 - coiled=1.45.0 + python=${{ envs.PYTHON_VERSION }} + coiled=${{ envs.COILED_VERSION }} - name: Run coiled login shell: bash + env: + INPUT_SERVER: ${{ inputs.server }} + INPUT_WORKSPACE: ${{ inputs.workspace }} + INPUT_TOKEN: ${{ inputs.token }} run: | - if [[ -n "${{ inputs.server }}" ]] && [[ -n "${{ inputs.workspace }}" ]]; then - micromamba run -n coiled-login coiled login --token ${{ inputs.token }} --workspace ${{ inputs.workspace }} --server ${{ inputs.server }} - elif [[ -n "${{ inputs.server }}" ]]; then - micromamba run -n coiled-login coiled login --token ${{ inputs.token }} --server ${{ inputs.server }} - elif [[ -n "${{ inputs.workspace }}" ]]; then - micromamba run -n coiled-login coiled login --token ${{ inputs.token }} --workspace ${{ inputs.workspace }} - else - micromamba run -n coiled-login coiled login --token ${{ inputs.token }} - fi + args=() + for input in token server workspace; do + var_name="INPUT_${input^^}" # Convert input to uppercase + var_name=$(echo "$var_name" | tr '-' '_') # Replace '-' with '_' + value="${!var_name}" # Use variable indirection to get the value + if [[ -n "$value" ]]; then + args+=("--$input" "$value") + fi + done + micromamba run -n coiled-run coiled login "${args[@]}" \ No newline at end of file