Skip to content

Commit

Permalink
new actions to update existing pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfiex committed Dec 1, 2023
1 parent 9852e40 commit ee03495
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 28 deletions.
Binary file added .github/.wiki/CMIP6plus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions .github/.wiki/CMIP6plus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions .github/.wiki/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A store of materials needed for the wiki
Binary file added .github/.wiki/cmip6plus600.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/.wiki/model_components.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/.wiki/source_id.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion .github/libs/source_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@

# sort out the model components
for c in component_list:
if c not in data: continue
cdummy = data[c][0]
model_components[c] = OrderedDict({"description": cdummy.get('description','none'),
"version":cdummy.get('version number','none'),
"native_nominal_resolution": cdummy.get('resolution','none') })

license = data['license(automated)'][0]
Expand All @@ -66,7 +68,7 @@
"license": license['license_id'],
"url": license['license_url'],
"exceptions_contact": "@%s <- %s"%tuple(data['license_exceptions_contact'].split('@')[::-1]),
"history": data.get('license_history',''),
# "history": data.get('license_history',''),
"source_specific_info": data.get("source_specific_info",''),

}),
Expand Down
87 changes: 74 additions & 13 deletions .github/workflows/source_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,29 @@ jobs:
GITHUB_USERNAME: ${{ github.event.client_payload.author }}
run: |
repository="${{ github.repository }}"
github_token="${{ secrets.GITHUB_TOKEN }}"
base_branch="main"
feature_branch="source_id_${{ github.event.client_payload.name }}"
git pull
git checkout -b $feature_branch;
remote_branch="origin/$feature_branch"
branch_info=$(git rev-parse --verify "$remote_branch" 2>&1)
echo "branch info: $branch_info"
if [ -n "$branch_info" ]; then
git checkout $feature_branch
git reset --hard origin/main
else
git checkout -b $feature_branch;
fi
content=$(python .github/libs/source_id.py -k ${{ github.event.client_payload.key }} -r ${{ github.event.client_payload.record }})
git config --global user.email "${GITHUB_USERNAME}@users.noreply.github.com"
Expand All @@ -76,18 +93,62 @@ jobs:
git add *source_id.json
git commit -m "Adding ${{ github.event.client_payload.name }} to source_id"
git push origin $feature_branch
git push origin $feature_branch --force
gh pr create --base $base_branch --head $feature_branch --title "New Source ID - add ${{ github.event.client_payload.name }}" --body \
"This pull request was automatically created by a GitHub Actions workflow.
Data submitted by @${{github.event.client_payload.author}}
Adding the following new data.
\`\`\`json
$content
\`\`\`
" --reviewer $GITHUB_USERNAME
if [ -n "$branch_info" ]; then
pull_requests=$(curl -s -H "Authorization: token $github_token" \
"https://api.github.com/repos/$repository/pulls?state=open&head=$feature_branch" | jq -r '.[].number')
# base is main, head is our branch.
echo "pull requests ${pull_requests}";
# Iterate through each pull request and add the comment
for pr_number in $pull_requests; do
# author=$(curl -s -H "Authorization: token $github_token" \
# "https://api.github.com/repos/$repository/pulls/$pr_number" | jq -r '.user.login')
echo "running pull request $pr_number" ;
# keep indentation of comment_body !important
comment_body="This pull request (#$pr_number) was automatically updated by a GitHub Actions workflow.

Data submitted by @${{github.event.client_payload.author}}

Adding the following updated data.
\`\`\`json
$content
\`\`\`
"
# escaped=$(echo "$comment_body" | sed 's/"/\\"/g')
echo "comment- $comment_body"

# # Add comment to the pull request
# curl -s -H "Authorization: token $github_token" \
# -x POST -d '{"body": "$comment_body"}' \
# "https://api.github.com/repos/$repository/issues/$pr_number/comments"
# # > /dev/null

gh pr comment $pr_number --body "$comment_body"

echo "Comment added to pull request #$pr_number"
done

else


echo "clean pull"
gh pr create --base $base_branch --head $feature_branch --title "New Source ID - add ${{ github.event.client_payload.name }}" --body \
"This pull request was automatically created by a GitHub Actions workflow.
Data submitted by @${{github.event.client_payload.author}}
Adding the following new data.
\`\`\`json
$content
\`\`\`
" --reviewer $GITHUB_USERNAME


fi

1 change: 1 addition & 0 deletions 2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8bd4ab6d051269250878053a78550cbd869dc398
26 changes: 13 additions & 13 deletions CVs/CMIP6Plus_CV.json
Original file line number Diff line number Diff line change
Expand Up @@ -824,16 +824,16 @@
}
},
"source_type": [
"AOGCM",
"AGCM",
"ISM",
"RAD",
"CHEM",
"AER",
"BGC",
"OGCM",
"SLAB",
"AOGCM",
"CHEM",
"LAND",
"ISM",
"AGCM",
"AER"
"SLAB",
"OGCM"
],
"sub_experiment_id": {
"f2023": "Forcings 2023",
Expand Down Expand Up @@ -926,17 +926,17 @@
"r[[:digit:]]\\{1,\\}i[[:digit:]]\\{1,\\}p[[:digit:]]\\{1,\\}f[[:digit:]]\\{1,\\}$"
],
"version_metadata": {
"file_updated": "Wed Nov 29 2023 20:07 UTC",
"checksum": "md5: b58d180fb606ec2f1bdbf3a7c2c16284",
"file_updated": "Fri Dec 01 2023 00:46 UTC",
"checksum": "md5: 9df16d5fbc8535b6face1808460afe71",
"CVs": {
"updated": "2023-11-29T20:06:39Z",
"updated": "2023-12-01T00:45:53Z",
"tag": "v6.5.0.0",
"commit": "b3bd7bde5b4aae11ff5558212134ac34f504da6c"
"commit": "0e7555baae3a5c24dbf80756b6720d89c38c2f4f"
},
"MIP tables": {
"updated": "2023-11-28T22:38:28Z",
"updated": "2023-11-30T15:33:29Z",
"tag": "v6.5.0.0",
"commit": "32a28db93193883d644560b3b36410c2e85c5eb5",
"commit": "49d4cfb8bca2f0bbed3608f278e7261f02e28c16",
"url": "https://www.github.com/repos/PCMDI/mip-cmor-tables"
},
"autogenerated": "True"
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# CMIP6Plus_CVs
# CMIP6Plus Controlled Vocabularies

Core Controlled Vocabularies (CVs) for use in CMIP6Plus
#


<div align="center" style="width:100%">
<img width='180px' style='fill:red;' src='https://raw.githubusercontent.com/WCRP-CMIP/CMIP6Plus_CVs/main/.github/.wiki/cmip6plus600.png'/>
<br>
<table>
<tr>
<td><strong>Description</strong></td>
Expand Down Expand Up @@ -41,6 +43,10 @@ Core Controlled Vocabularies (CVs) for use in CMIP6Plus

#

## For information on how to interact
Visit the wiki using the button above, or [this link](https://github.com/WCRP-CMIP/CMIP6Plus_CVs/wiki)

## Currently active MIPs

To see a listing of currently active or planning activities/MIPs, please review details on the [Model Intercomparison Projects (MIPs)](https://wcrp-cmip.org/model-intercomparison-projects-mips/) page on the CMIP website.

Expand Down

0 comments on commit ee03495

Please sign in to comment.