Skip to content

Commit 0050ff6

Browse files
Merge pull request #14 from thomasbtf/containerize
feat: add containerize support
2 parents 312b313 + b8c43de commit 0050ff6

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

.github/workflows/main.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,22 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v1
14-
- uses: ./
14+
15+
- name: Test run
16+
uses: ./
17+
with:
18+
directory: .test
19+
snakefile: .test/Snakefile
20+
args: "--cores 1"
21+
22+
- name: Test containerize
23+
uses: ./
1524
with:
1625
directory: .test
1726
snakefile: .test/Snakefile
1827
args: "--cores 1"
28+
task: "containerize"
29+
30+
- name: Show Dockerfile
31+
run: |
32+
cat Dockerfile

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,31 @@ Additional arguments to pass to Snakemake.
2020

2121
Preliminary commands to run before the workflow execution.
2222

23+
### `task`
24+
25+
Whether to run Snakemake or to generate a container image specification (in the form of a Dockerfile) that contains all required environments. Can be either `run` or `containerize`. Default `run`.
26+
2327
## Example usage
2428

2529
```yaml
2630
- name: Linting
27-
uses: snakemake/snakemake-github-action@v1.19.0
31+
uses: snakemake/snakemake-github-action@v1
2832
with:
2933
directory: '.test'
3034
snakefile: 'workflow/Snakefile'
3135
args: '--lint'
36+
3237
- name: Testing
33-
uses: snakemake/snakemake-github-action@v1.19.0
38+
uses: snakemake/snakemake-github-action@v1
3439
with:
3540
directory: '.test'
3641
snakefile: 'workflow/Snakefile'
3742
args: '--cores 1 --use-conda --conda-cleanup-pkgs cache'
3843
stagein: '' # additional preliminary commands to run (can be multiline)
44+
45+
- name: Create container file
46+
uses: snakemake/snakemake-github-action@v1
47+
with:
48+
snakefile: 'workflow/Snakefile'
49+
run: 'containerize'
3950
```

action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ inputs:
2222
description: Additional steps to prepare the workflow for execution
2323
required: false
2424
default: ''
25+
task:
26+
description: Whether to run Snakemake or to generate a container image specification.
27+
required: false
28+
default: 'run'
2529

2630
runs:
2731
using: 'docker'
@@ -31,3 +35,4 @@ runs:
3135
- ${{ inputs.snakefile }}
3236
- ${{ inputs.args }}
3337
- ${{ inputs.stagein }}
38+
- ${{ inputs.task }}

entrypoint.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ mkdir -p /github/workspace/.conda
55
# run given stagein command
66
eval "$4"
77

8-
# run snakemake with given args
9-
snakemake --directory $1 --snakefile $2 --show-failed-logs $3
10-
8+
# create container file
9+
if [ "$5" = 'containerize' ] ; then
10+
snakemake --directory $1 --snakefile $2 --show-failed-logs $3 --containerize > Dockerfile
11+
elif [ "$5" = 'run' ] ; then
12+
# run snakemake with given args
13+
snakemake --directory $1 --snakefile $2 --show-failed-logs $3
14+
else
15+
echo "Task input not recognized." && exit 1
16+
fi

0 commit comments

Comments
 (0)