repo-update #2775
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: repo-update | |
on: | |
push: | |
paths: | |
- assets/repos/** | |
- .github/workflows/repo-update.yml | |
schedule: | |
- cron: "0 */6 * * *" | |
workflow_dispatch: | |
jobs: | |
repo-update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref_name }} | |
- name: update repos | |
run: | | |
export user=ZoeyVid | |
export domain=zoeyvid.de | |
export path=assets/repos | |
rm -rf $path | |
mkdir -p $path | |
for repo in $(curl -sL https://api.github.com/orgs/$user/repos?per_page=1000 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r ".[] | select(.archived==false) | select(.private==false) | .name" | grep -v "^.github$" | sort); do echo -e "<meta charset="utf-8">\n$(curl -X POST https://api.github.com/markdown/raw --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --header "Content-Type: text/plain" -d "$(curl -sL https://raw.githubusercontent.com/$user/$repo/$(curl -sL "https://api.github.com/repos/$user/$repo" --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r ".default_branch")/README.md)")\n" | tee $path/$repo.html; done; | |
echo { | tee -a $path/repos.json | |
for repo in $(curl -sL https://api.github.com/orgs/$user/repos?per_page=1000 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r ".[] | select(.archived==false) | select(.private==false) | .name" | grep -v "^.github$" | sort); do echo \"$repo\": { \"name\": \"$repo\", \"html_url\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.html_url')\", \"readme\": \"https://$domain/$path/$repo.html\", \"fork\": $(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.fork'), \"description\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.description')\", \"topics\": [ $(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq '.topics[]' | sed ':a;N;$!ba;s/\n/, /g') ], \"homepage\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.homepage')\", \"spdx_id\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.license.spdx_id')\"}, | tee -a $path/repos.json; done; | |
sed -i '$ d' $path/repos.json | |
for repo in $(curl -sL https://api.github.com/orgs/$user/repos?per_page=1000 --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r ".[] | select(.archived==false) | select(.private==false) | .name" | grep -v "^.github$" | sort -r | head -n 1); do echo \"$repo\": { \"name\": \"$repo\", \"html_url\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.html_url')\", \"readme\": \"https://$domain/$path/$repo.html\", \"fork\": $(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.fork'), \"description\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.description')\", \"topics\": [ $(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq '.topics[]' | sed ':a;N;$!ba;s/\n/, /g') ], \"homepage\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.homepage')\", \"spdx_id\": \"$(curl -sL https://api.github.com/repos/$user/$repo --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq -r '.license.spdx_id')\"} | tee -a $path/repos.json; done; | |
echo } | tee -a $path/repos.json | |
jq -r tostring $path/repos.json | tee $path/index.json | |
sed -i "s|\"null\"|\"\"|g" $path/index.json | |
rm -rf $path/repos.json | |
- name: json-syntax-check | |
uses: limitusus/json-syntax-check@v2 | |
with: | |
pattern: "\\.json$*" | |
- name: push changes | |
run: | | |
git config user.name "GitHub" | |
git config user.email "[email protected]" | |
git add -A | |
git diff-index --quiet HEAD || git commit -sm "update repos" | |
git push |