Skip to content

Commit b4e24ba

Browse files
authored
bring your own environment
1 parent 4e2fd67 commit b4e24ba

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ Whether to run Snakemake or to generate a container image specification (in the
2828

2929
Whether used disk space shall be printed if Snakemake fails. Can be either `true` or `false` (default: `false`).
3030

31+
### `snakemake version`
32+
33+
Snakemake version to use. If not specified, uses latest version. Pin a specific version (e.g., '8.25.5') for reproducibility.
34+
35+
### `install-apptainer`
36+
37+
Install Apptainer (true/false)
38+
39+
### `environment-file`
40+
41+
Path to a custom Conda environment file containing snakemake (e.g., 'etc/custom-environment.yml'). If not specified, a default environment with snakemake is generated.
42+
3143
## Example usage
3244

3345
```yaml
@@ -46,6 +58,7 @@ Whether used disk space shall be printed if Snakemake fails. Can be either `true
4658
args: '--cores 1 --sdm conda --conda-cleanup-pkgs cache'
4759
stagein: '' # additional preliminary commands to run (can be multiline)
4860
show-disk-usage-on-error: true
61+
environment-file: 'my-environment.yaml'
4962

5063

5164
- name: Create container file

action.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ inputs:
3838
description: Install Apptainer (true/false)
3939
required: false
4040
default: false
41+
environment-file:
42+
description: Path to a custom Conda environment file containing snakemake (e.g., 'etc/custom-environment.yml'). If not specified, a default environment with snakemake is generated.
43+
required: false
44+
default: ''
4145

4246
runs:
4347
using: 'composite'
@@ -59,7 +63,9 @@ runs:
5963
fi
6064
sudo apt-get update
6165
sudo apt-get install -y apptainer
66+
6267
- name: Prepare .snakemake.environment.yaml
68+
if: ${{ inputs.environment-file == '' }}
6369
shell: bash -el {0}
6470
run: |
6571
cat <<EOF > .snakemake.environment.yaml
@@ -71,13 +77,24 @@ runs:
7177
- snakemake ==${{ inputs.snakemake-version }}
7278
EOF
7379
80+
- name: Validate custom environment file
81+
if: ${{ inputs.environment-file != '' }}
82+
shell: bash -el {0}
83+
run: |
84+
if [[ -f "${{ inputs.environment-file }}" ]]; then
85+
echo "Using custom environment file: ${{ inputs.environment-file }}"
86+
else
87+
echo "Error: Custom environment file '${{ inputs.environment-file }}' not found"
88+
exit 1
89+
fi
90+
7491
- name: Setup conda
7592
uses: conda-incubator/setup-miniconda@v3
7693
with:
7794
channels: conda-forge,bioconda
7895
channel-priority: strict
7996
miniforge-version: latest
80-
environment-file: .snakemake.environment.yaml
97+
environment-file: ${{ inputs.environment-file != '' && inputs.environment-file || '.snakemake.environment.yaml' }}
8198
activate-environment: snakemake
8299

83100
- name: Display snakemake version

0 commit comments

Comments
 (0)