Conda lock files #109
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate conda-lock | |
# When environment.yml is changed | |
on: | |
pull_request: | |
paths: | |
- "**/environment.yml" | |
jobs: | |
gen-matrix: | |
name: generate-matrix | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
- name: Calculate file differences | |
id: diff | |
uses: tj-actions/changed-files@v44 | |
with: | |
json: true | |
quotepath: false | |
files: | | |
modules/**/environment.yml | |
- name: Debug | |
run: echo ${{ steps.diff.outputs.all_changed_files }} | |
- id: set-matrix | |
run: echo "matrix={\"files\":${{ steps.diff.outputs.all_changed_files }} }" >> "$GITHUB_OUTPUT" | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
lock: | |
if: "${{ fromJson(needs.gen-matrix.outputs.matrix) }}" | |
needs: gen-matrix | |
name: Generate conda-lock file | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: "${{ fromJson(needs.gen-matrix.outputs.matrix) }}" | |
steps: | |
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4 | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: conda-lock-env | |
create-args: >- | |
python=3.11 | |
conda-lock | |
mamba | |
- name: Get the lock file path | |
uses: actions/github-script@v7 | |
id: lockfile-name | |
with: | |
result-encoding: string | |
script: | | |
return '${{ matrix.files }}'.replace('/environment.yml', '/conda-lock.yml'); | |
- name: Run conda-lock | |
run: | | |
rm --force "${{steps.lockfile-name.outputs.result}}" | |
conda-lock lock $MAMBA --file "${{ matrix.files }}" --kind lock --platform linux-64 --lockfile "${{steps.lockfile-name.outputs.result}}" | |
env: | |
MAMBA: "--mamba" | |
shell: bash -l {0} | |
- name: Commit & push changes | |
id: commit-and-push | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "nf-core-bot" | |
git config push.default upstream | |
git add . | |
git status | |
git commit -m "[automated] autogenerated conda-lock file" | |
git push | |
- name: If no conda-lock update | |
if: steps.commit-and-push.outcome == 'failure' | |
run: | | |
echo "No conda-lock update" | |
# TODO Build containers with Wave |