condalock-command #91
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
# 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 | |
# Generate unified 'conda-lock.yml' and platform-specific lockfiles | |
- name: Run conda-lock | |
run: | | |
conda-lock lock --mamba --file environment.yml --platform linux-64 | |
conda-lock render --kind explicit --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 |