Skip to content

Commit

Permalink
Merge pull request #14 from thomasbtf/containerize
Browse files Browse the repository at this point in the history
feat: add containerize support
  • Loading branch information
johanneskoester authored Sep 20, 2021
2 parents 312b313 + b8c43de commit 0050ff6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: ./

- name: Test run
uses: ./
with:
directory: .test
snakefile: .test/Snakefile
args: "--cores 1"

- name: Test containerize
uses: ./
with:
directory: .test
snakefile: .test/Snakefile
args: "--cores 1"
task: "containerize"

- name: Show Dockerfile
run: |
cat Dockerfile
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,31 @@ Additional arguments to pass to Snakemake.

Preliminary commands to run before the workflow execution.

### `task`

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`.

## Example usage

```yaml
- name: Linting
uses: snakemake/snakemake-github-action@v1.19.0
uses: snakemake/snakemake-github-action@v1
with:
directory: '.test'
snakefile: 'workflow/Snakefile'
args: '--lint'

- name: Testing
uses: snakemake/snakemake-github-action@v1.19.0
uses: snakemake/snakemake-github-action@v1
with:
directory: '.test'
snakefile: 'workflow/Snakefile'
args: '--cores 1 --use-conda --conda-cleanup-pkgs cache'
stagein: '' # additional preliminary commands to run (can be multiline)

- name: Create container file
uses: snakemake/snakemake-github-action@v1
with:
snakefile: 'workflow/Snakefile'
run: 'containerize'
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ inputs:
description: Additional steps to prepare the workflow for execution
required: false
default: ''
task:
description: Whether to run Snakemake or to generate a container image specification.
required: false
default: 'run'

runs:
using: 'docker'
Expand All @@ -31,3 +35,4 @@ runs:
- ${{ inputs.snakefile }}
- ${{ inputs.args }}
- ${{ inputs.stagein }}
- ${{ inputs.task }}
12 changes: 9 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ mkdir -p /github/workspace/.conda
# run given stagein command
eval "$4"

# run snakemake with given args
snakemake --directory $1 --snakefile $2 --show-failed-logs $3

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

0 comments on commit 0050ff6

Please sign in to comment.