generated from 2i2c-org/hub-user-image-template
-
Notifications
You must be signed in to change notification settings - Fork 7
70 lines (61 loc) · 2.35 KB
/
conda-lock-command.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 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