forked from ersilia-os/ersilia
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (145 loc) · 6.04 KB
/
approve-dispatch.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: Approve Command Dispatch
on:
repository_dispatch:
types: [ approve-command ]
permissions:
issues: write
contents: read
jobs:
approve-command-dispatch:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # [email protected]
# parse the issue body from free form text to a structured JSON object
- name: parse issue
uses: GrantBirki/[email protected]
id: issue-parser
with:
body: ${{ github.event.client_payload.github.payload.issue.body }}
# echo the parsed issue body to the console for debugging if we need to
- name: echo body
run: echo $ISSUE_BODY
env:
ISSUE_BODY: ${{ steps.issue-parser.outputs.json }}
# setup python
- name: setup python
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # [email protected]
with:
python-version: "3.10"
# cache: 'pip' # caching pip dependencies
# setup conda
- name: add conda to system path
run: echo $CONDA/bin >> $GITHUB_PATH
- name: source conda
run: source $CONDA/etc/profile.d/conda.sh
- name: install dependencies through conda
run: |
source activate
conda init
conda install git-lfs -c conda-forge
git-lfs install
conda install gh -c conda-forge
# add PyGithub to the conda environment
- name: add PyGithub to conda environment
run: |
source activate
conda install -c conda-forge pygithub
# create the model repo from the template
- name: create model repo
id: create-model-repo
env:
GITHUB_TOKEN: ${{ secrets.PAT }} # PAT for the ersilia-bot GitHub account
OWNER: ersilia-os
JSON: ${{ steps.issue-parser.outputs.json }}
TEMPLATE: ersilia-os/eos-template
FLAGS: --public
run: |
REPO_NAME=$(python3 .github/scripts/generate_eos_identifier.py)
gh repo create ${OWNER}/${REPO_NAME} --template $TEMPLATE $FLAGS
echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT
# commit updates to the metadata.json file
- name: commit metadata.json
id: update-metadata
env:
GITHUB_TOKEN: ${{ secrets.PAT }} # PAT for the ersilia-bot GitHub account
OWNER: ersilia-os
REPO: ${{ steps.create-model-repo.outputs.repo_name }}
JSON: ${{ steps.issue-parser.outputs.json }}
run: |
python3 .github/scripts/update_metadata.py
# upload git-lfs object
- name: checkout persist credentials
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # [email protected]
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: remove ersilia repo
run: |
rm -rf *
- name: clone the repository
uses: GuillaumeFalourd/clone-github-repo-action@62795acaa4a02f89824de75c7025459a9cabaa45 # pin@v3
with:
owner: 'ersilia-os'
repository: ${{ steps.create-model-repo.outputs.repo_name }}
- name: create a mock git-lfs object to enable contributions
id: mock-lfs
env:
REPO: ${{ steps.create-model-repo.outputs.repo_name }}
run: |
cd $REPO
git lfs install
echo "This is a mock git lfs file" > mock.txt
git lfs track mock.txt
git add .gitattributes
git add mock.txt
git lfs ls-files
- name: commit and push changes
uses: actions-js/push@156f2b10c3aa000c44dbe75ea7018f32ae999772 # [email protected]
with:
author_name: "ersilia-bot"
author_email: "[email protected]"
message: "mock lfs [skip ci]"
directory: ${{ steps.create-model-repo.outputs.repo_name }}
repository: "ersilia-os/${{ steps.create-model-repo.outputs.repo_name }}"
github_token: ${{ secrets.PAT }}
amend: true
force: true
# sync metadata to airtable
# now that the repo has been created, and the metadata.json file has been updated, we can sync the metadata to airtable
- name: sync metadata to airtable
id: sync-metadata-to-airtable
env:
REPO_NAME: ${{ steps.create-model-repo.outputs.repo_name }}
REPO: ersilia
OWNER: ersilia-os
ISSUE_NUMBER: ${{ github.event.client_payload.github.payload.issue.number }}
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
source activate
ISSUE_CREATOR=$(gh api /repos/${OWNER}/${REPO}/issues/${ISSUE_NUMBER} | jq -r '.user.login')
echo "issue_creator=${ISSUE_CREATOR}"
python3 -m pip install pyairtable
python3 -m pip install requests
python3 .github/scripts/insert_metadata_to_airtable.py $REPO_NAME $ISSUE_CREATOR $AIRTABLE_API_KEY
# find the creator of the issue
- name: find original issue creator
id: issue-creator
env:
ISSUE_NUMBER: ${{ github.event.client_payload.github.payload.issue.number }}
OWNER: ersilia-os
REPO: ersilia
GH_TOKEN: ${{ github.token }}
run: |
ISSUE_CREATOR=$(gh api /repos/${OWNER}/${REPO}/issues/${ISSUE_NUMBER} | jq -r '.user.login')
echo "issue_creator=${ISSUE_CREATOR}" >> $GITHUB_OUTPUT
# comment on the issue comment with further instructions for the user
- name: comment
uses: GrantBirki/comment@7016e89e8f225b0f18f1fbb7fd10263df2772a05 # [email protected]
with:
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
file: .github/templates/new-model.md
vars: |
repo_name: ${{ steps.create-model-repo.outputs.repo_name }}
issue_creator: ${{ steps.issue-creator.outputs.issue_creator }}