Updating all python modules CI github workflow

The script bellow enable to update one file across many github repositories a better alternative could be to use submodule for the github actions

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 #!/bin/bash # Author: Patrick Delcroix # Email: patrick.delcroix@swisstph.ch # Created Date: 17.01.2022 # Credit: https://www.middlewareinventory.com/blog/github-list-all-repositories-using-rest-api/ FILENAME=openmis-module-test.yml KEYWORD=jobs ORG=openimis USERNAME= TOKEN= userdata=`curl -u $USERNAME:$TOKEN -H "Accept: application/vnd.github.v3+json" -s "https://api.github.com/users/${USERNAME}"` echo $userdata > userdata.json useremail=$(jq -r '.email' <<< $userdata) username=$(jq -r '.name' <<< $userdata) echo $username echo $useremail git config --global credential.helper 'store --file ~/.my-credentials' echo "https://${TOKEN}:x-oauth-basic@github.com" > ~/.my-credentials git config --global user.email $useremail git config --global user.name $username # No of reposoitories per page - Maximum Limit is 100 PERPAGE=100 # Change the BASEURL to your Org or User based # Org base URL BASEURL="https://api.github.com/search/code?q=${KEYWORD}+org:${ORG}+filename:${FILENAME}" # User base URL # BASEURL="https://api.github.com/user/<your_github_username>/repos" # Calculating the Total Pages after enabling Pagination i=0 if test -f "$FILENAME"; then echo "${BASEURL}&per_page\=${PERPAGE}" #TOTALPAGES=`curl -I -i -u $USERNAME:$TOKEN -H "Accept: application/vnd.github.v3+json" -s "${BASEURL}&per_page=${PERPAGE}" | grep -i link: 2>/dev/null|sed 's/link: //g'|awk -F',' -v ORS='\n' '{ for (i = 1; i <= NF; i++) print $i }'|grep -i last|awk '{print $1}' | tr -d '\<\>' | tr '\?\&' ' '|awk '{print $3}'| tr -d '=;page'` #TOTALPAGES=0 #until [ $i -gt $TOTALPAGES ] #do echo "page=${i}" tempfile=`curl -s -u $USERNAME:$TOKEN -H 'Accept: application/vnd.github.v3+json' "${BASEURL}&per_page=${PERPAGE}&page=${i}" 2>&1` #echo $result > tempfile # get the page numer of result unset results eval "$( jq -r '@sh "results=\(.items|length)"' <<< "$tempfile" )" if [ -z "$results" ]; then echo 'Failed to parse number of results' >&2 exit 1 fi for (( l = 0; l < results; ++l )); do unset url unset path unset name eval "$( jq -r --argjson l "$l" ' .items[$l] | @sh "url=\(.repository.html_url)", @sh "path=\(.path)", @sh "repo=\(.repository.name)"' <<< "$tempfile" )" echo "url:${url}, repo:${repo}.git ${path}" git clone --depth 1 --branch develop $url $repo cd $repo BRANCH="bulk-update-${FILENAME}" git checkout -b $BRANCH cp ../$FILENAME $path -f git commit $path -m $BRANCH git push -u origin $BRANCH POST_DATA="{\"title\":\"${BRANCH}\", \"base\":\"develop\", \"head\":\"${BRANCH}\"}" echo $POST_DATA curl -H "Accept: application/vnd.github.v3+json" -u $USERNAME:$TOKEN -s "https://api.github.com/repos/${ORG}/${repo}/pulls" -d "${POST_DATA}" echo $pr cd .. done #done fi