@@ -2,25 +2,33 @@ name: Setup conda env
22description : Setup conda environment for Python
33inputs :
44 cache-number :
5- description : ' Cache number to reset cache if conda lock file has not changed'
5+ description : Cache number to reset cache if conda lock file has not changed
66 required : true
77 type : number
88 python-version :
9- description : ' Python version to use'
9+ description : Python version to use
1010 required : true
1111 type : string
12+ virtual-repo-names :
13+ description : ' List of repository names to pull from (e.g. ["geology-conda-dev", "geophysics-conda-dev"])'
14+ required : false
15+ type : string
16+ conda-channels :
17+ description : ' List of conda channels to pull from (e.g. ["conda-forge", "pytorch"])'
18+ required : false
19+ type : string
1220 JFROG_ARTIFACTORY_URL :
13- description : ' JFrog Artifactory URL, needed if packages are on Artifactory'
21+ description : JFrog Artifactory URL, needed if packages are on Artifactory (secret)
1422 required : false
1523 type : string
1624 JFROG_ARTIFACTORY_TOKEN :
17- description : ' JFrog Artifactory Token, needed if packages are on Artifactory'
25+ description : JFrog Artifactory Token, needed if packages are on Artifactory (secret)
1826 required : false
1927 type : string
2028
2129
2230runs :
23- using : " composite"
31+ using : composite
2432 steps :
2533 - uses : actions/checkout@v5
2634 with :
4957 INPUTS_JFROG_ARTIFACTORY_TOKEN : ${{ inputs.JFROG_ARTIFACTORY_TOKEN }}
5058 run : |
5159 micromamba auth login ${INPUTS_JFROG_ARTIFACTORY_URL} -u github -p ${INPUTS_JFROG_ARTIFACTORY_TOKEN}
60+ - name : Configure Conda channels
61+ id : config-channels
62+ shell : ' bash -l {0}'
63+ env :
64+ INPUTS_JFROG_ARTIFACTORY_URL : ${{ inputs.JFROG_ARTIFACTORY_URL }}
65+ INPUTS_SOURCE_REPO_NAMES : ${{ inputs.virtual-repo-names }}
66+ INPUTS_CONDA_CHANNELS : ${{ inputs.conda-channels }}
67+ run : |
68+ conda_channels=""
69+ repository_list=$(echo "${INPUTS_SOURCE_REPO_NAMES}" | jq -r '.[]' | xargs)
70+ echo "Using local Conda channels: ${repository_list}"
71+ for repo_name in ${repository_list}; do
72+ url="https://${INPUTS_JFROG_ARTIFACTORY_URL}/artifactory/api/conda/${repo_name}"
73+ conda_channels="${conda_channels}${url},"
74+ done
75+
76+ channel_list=$(echo "${INPUTS_CONDA_CHANNELS}" | jq -r '.[]' | xargs)
77+ # at the minimum use conda-forge
78+ if [[ -z $channel_list ]]; then
79+ channel_list=conda-forge
80+ fi
81+ echo "Using regular Conda channels: $channel_list"
82+ for channel_name in ${channel_list}; do
83+ conda_channels="${conda_channels}${channel_name},"
84+ done
85+ conda_channels="${conda_channels%,}"
86+
87+ echo "channels=$conda_channels" >> $GITHUB_OUTPUT
5288 - name : Create conda env
5389 uses : mamba-org/setup-micromamba@v2
5490 with :
6399 PYTHONUTF8 : 1
64100 CONDA_CHANNEL_PRIORITY : strict
65101 MAMBA_CHANNEL_PRIORITY : strict
66- PIP_NO_DEPS : 1 # all dependencies are installed from conda
67- CONDA_LOCK_ENV_FILE : ' environments/py-${{ inputs.python-version }}-${{ env.os_conda }}-64-dev.conda.lock.yml'
102+ CONDA_CHANNELS : ${{ steps.config-channels.outputs.channels }}
103+ MAMBA_CHANNELS : ${{ steps.config-channels.outputs.channels }}
104+ PIP_NO_DEPS : 1 # all dependencies are explicitly listed in the conda lock file
105+ CONDA_LOCK_ENV_FILE : environments/py-${{ inputs.python-version }}-${{ env.os_conda }}-64-dev.conda.lock.yml
0 commit comments