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 271df8f
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 25 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
22 changes: 22 additions & 0 deletions .github/workflows/getting workflow actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch" | jq -r '.workflow_runs |keys'


last run => 0
curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch&name=Source_ID_dispatch" | jq -r '.workflow_runs[0] '


rerunurl

curl -s -H "Authorization: token $github_token" "https://api.github.com/repos/$repository/actions/runs?event=repository_dispatch&name=Source_ID_dispatch" | jq -r '.workflow_runs[0].rerun_url'


# Set your GitHub token and repository variables
github_token="$(gh auth token)"
repository="WCRP-CMIP/CMIP6Plus_CVs"
workflow_run_id="7054479259"

# Trigger a new workflow dispatch event for the specified run
curl -X POST \
-H "Authorization: token $github_token" \
-H "Accept: application/vnd.github.everest-preview+json" \
"https://api.github.com/repos/$repository/actions/runs/$workflow_run_id/rerun"
84 changes: 73 additions & 11 deletions .github/workflows/source_id.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,31 @@ 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;
git pull
remote_branch="origin/$feature_branch"
echo "bi"
branch_info=$(git rev-parse --verify "$remote_branch" >/dev/null 2>&1 || true)
echo "branch info: $branch_info"
if [ -n "$branch_info" ]; then
echo "checkout existing"
git checkout $feature_branch
git reset --hard origin/main
else
echo "checkout new"
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 +95,61 @@ 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.
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 new data.
Adding the following updated data.
\`\`\`json
$content
\`\`\`
" --reviewer $GITHUB_USERNAME
$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
24 changes: 12 additions & 12 deletions CVs/CMIP6Plus_CV.json
Original file line number Diff line number Diff line change
Expand Up @@ -824,16 +824,16 @@
}
},
"source_type": [
"AOGCM",
"RAD",
"AER",
"CHEM",
"AOGCM",
"AGCM",
"ISM",
"BGC",
"RAD",
"OGCM",
"SLAB",
"LAND",
"ISM",
"AGCM",
"AER"
"SLAB"
],
"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 02:13 UTC",
"checksum": "md5: fa35efde61948d1224f1012863310ba0",
"CVs": {
"updated": "2023-11-29T20:06:39Z",
"updated": "2023-12-01T02:12:44Z",
"tag": "v6.5.0.0",
"commit": "b3bd7bde5b4aae11ff5558212134ac34f504da6c"
"commit": "9c2f29390fdbc159452c3e0f6d10d89423fe11a8"
},
"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 271df8f

Please sign in to comment.