Skip to content

RAMIP: add experiments #389

RAMIP: add experiments

RAMIP: add experiments #389

name: File Versioning
on:
push:
branches:
- '*'
# tags:
# - '*'
workflow_run:
workflows: ["Generate CV file"]
types:
- completed
jobs:
update_versioning:
runs-on: ubuntu-latest
env:
API_KEY: ${{ secrets.API_KEY }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
# discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
# security-events: write
statuses: write
steps:
- name: Check out the repository
uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch the complete commit history
- name: Set up Git
run: |
git config user.email "actions@wcrp-cmip.org"
git config user.name "CMIP-IPO: Automated GitHub Action"
git config credential.helper store
git config --global user.email "actions@wcrp-cmip.org"
git config --global user.name "CMIP-IPO GitHub Action"
git config --global push.default current
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
shell: bash
- name: Update Versioning
id: run-python-script
run: python .github/libs/version.py -t ${GH_TOKEN} -b $(git rev-parse --abbrev-ref HEAD)
shell: bash
# - name: Persist All Changes - Job 1
# uses: actions/upload-artifact@v2
# with:
# name: version_changes
# path: .
- name: Write Changes
run: |
if [ -z "$ACT" ]; then
git push origin $(git rev-parse --abbrev-ref HEAD)
else
echo "Skipping this step in 'act' environment."
fi
shell: bash
continue-on-error: true
update_readme:
runs-on: ubuntu-latest
needs: update_versioning
steps:
- name: Checkout Repository
uses: actions/checkout@v2
# - name: Download Changes - Job 1
# uses: actions/download-artifact@v2
# with:
# name: version_changes
- name: Set up Git
run: |
git config user.email "actions@wcrp-cmip.org"
git config user.name "CMIP-IPO: Automated GitHub Action"
git config credential.helper store
git config --global user.email "actions@wcrp-cmip.org"
git config --global user.name "CMIP-IPO GitHub Action"
git config --global push.default current
echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
git pull
shell: bash
- name: Read JSON files and Update Counts
run: |
keys=("experiment_id" "source_id" "activity_id")
for key in "${keys[@]}"; do
count=$(jq ".${key} | length" *_${key}.json | head -n 1)
echo "$key=$count"
echo "$key=$count" >> $GITHUB_ENV
echo "$key length = $count" >> $GITHUB_STEP_SUMMARY
done
shell: bash
- name: Show Updated Counts
run: |
cat $GITHUB_ENV
- name: Update README
run: |
readme_section="<td><strong>Repository Contents</strong></td>
<td><img src='https://img.shields.io/badge/Activities-%20${activity_id}%20-purple'>
<img src='https://img.shields.io/badge/Experiments-%20${experiment_id}%20-coral'>
<img src='https://img.shields.io/badge/Sources-%20${source_id}%20-blue'></td></tr end>"
perl -0777 -i -pe "s|<td><strong>Repository Contents</strong></td>.*?</tr end>|${readme_section}|s" README.md
shell: bash
- name: Commit Changes
run: |
git add README.md
git commit -m "Updating repository description."
git config pull.rebase true
git pull origin $(git rev-parse --abbrev-ref HEAD)
git push origin $(git rev-parse --abbrev-ref HEAD)
continue-on-error: true
# - name: Push Changes
# uses: ad-m/github-push-action@master
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# push :
# runs-on: ubuntu-latest
# needs: [ update_versioning,update_readme ,]
# steps:
# - name: Checkout Repository
# uses: actions/checkout@v2
# - name: Download Changes - Job 1
# uses: actions/download-artifact@v2
# with:
# name: version_changes
# - name: Download Changes - Job 2
# uses: actions/download-artifact@v2
# with:
# name: readme_changes
# - name: Lets Push Changes
# run: echo "When all other Jobs Finish"
# - name: Set up Git
# run: |
# git config user.email "actions@wcrp-cmip.org"
# git config user.name "CMIP-IPO: Automated GitHub Action"
# git config credential.helper store
# git config --global user.email "actions@wcrp-cmip.org"
# git config --global user.name "CMIP-IPO GitHub Action"
# git config --global push.default current
# echo "GH_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
# shell: bash
# - name: Read Changes
# run: |
# if [ -z "$ACT" ]; then
# git pull
# else
# echo "Skipping this step in 'act' environment."
# fi
# shell: bash
# continue-on-error: true
# - name: Write Changes
# run: |
# if [ -z "$ACT" ]; then
# # git push origin $(git rev-parse --abbrev-ref HEAD)
# git push
# else
# echo "Skipping this step in 'act' environment."
# fi
# shell: bash
# continue-on-error: true
# - name: Check readme
# run: |
# if [ -z "$ACT" ]; then
# echo "$(more README.md)"
# else
# echo "Skipping this step in 'act' environment."
# fi
# shell: bash
# continue-on-error: true