Skip to content

condalock-command

condalock-command #53

# Runs conda-lock against environment.yml for reproducible environments
# Runs on any opened PR
name: Conda Lock
on:
repository_dispatch:
types: [condalock-command]
permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
condalock:
permissions:
contents: write # for Git to git push
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}
steps:
# Generate token from CryoInTheCloud bot
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# Checkout the pull request branch
- name: Checkout Repository
uses: actions/checkout@v3
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.ref }}
# Install conda-lock library with Micromamba
- name: Install conda-lock with Micromamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: conda-lock-env
create-args: >-
python=3.11
conda-lock
mamba
# Run "conda-lock" for linux-64 only
- name: Run conda-lock
run: |
conda-lock lock --mamba --kind explicit --file environment.yml --platform linux-64
# Commit the change to the PR branch if any changes
- name: Commit condalock files to PR
run: |
if [[ $(git ls-files --modified --others) ]]; then
git config --global user.name 'actions-bot'
git config --global user.email '[email protected]'
git commit --all --message "[condalock-command] autogenerated conda-lock files"
git push
fi
# Add an emoji reaction to comment to indicate the script completed successfully
- name: Add reaction
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray