diff --git a/.github/workflows/techRadar/update_used_dependencies.sh b/.github/workflows/techRadar/update_used_dependencies.sh new file mode 100755 index 0000000..6dd3b38 --- /dev/null +++ b/.github/workflows/techRadar/update_used_dependencies.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +repository_names=$( + echo $0 \ + | jq '.[] | .nameWithOwner' +) + +# Folder where temporary data will be stored +mkdir -p .packageManagers + +# Load all the dependencies data +for name in $repository_names; do + # Get the list of dependencies by package manager + dependencies=$( + gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/$name/dependency-graph/sbom \ + --jq '[ .sbom.packages.[] | { name: .name | sub("[a-zA-Z.]+[:/](?.*)"; "\(.package)"), packageManager: .name | capture("(?[a-zA-Z.]+)[:/]").packageManager, version: .versionInfo } ] | reduce .[] as { $name, $packageManager, $version } ( {}; .[ $packageManager ] += [ $name + " v" + $version ] )' + ) + + # Extract the list of package managers + packageManagers=$( + echo $dependencies \ + | jq -r '. | keys[]' + ) + + # Store the dependencies by package manager in specific files + for packageManager in $packageManagers; do + echo $dependencies \ + | jq -r ".$packageManager[]" \ + >> .packageManagers/$packageManager + done +done + +# Filter the resulting dependencies +for file in $(ls .packageManagers); do + if [[ -s .packageManagers/$file ]]; then + cat .packageManagers/$file | sort | uniq > .packageManagers/${file}_sorted + mv .packageManagers/${file}_sorted .packageManagers/$file + else + rm .packageManagers/$file + fi +done + +# Update the Markdown file with the extracted data +markdown_file="public/techRadar/used_dependencies.md" + +echo -e "# Used dependencies\n" > $markdown_file + +for file in $(ls .packageManagers); do + echo -e "## $file\n" >> $markdown_file + + while read -r line; do + echo -e "- $line" >> $markdown_file + done < .packageManagers/$file + + echo -e "" >> $markdown_file +done diff --git a/.github/workflows/techRadar/update_used_languages.sh b/.github/workflows/techRadar/update_used_languages.sh new file mode 100755 index 0000000..893bee3 --- /dev/null +++ b/.github/workflows/techRadar/update_used_languages.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo $0 \ + | jq '. | reduce .[] as { $name, $primaryLanguage, $url } ( {}; .[ $primaryLanguage.name | tostring ][$name] = $url )' \ + | gomplate -d repositories=stdin:///in.json -f techRadar/used_languages.tmpl -o public/techRadar/used_languages.md diff --git a/.github/workflows/tech_radar.yml b/.github/workflows/tech_radar.yml new file mode 100644 index 0000000..e5760e9 --- /dev/null +++ b/.github/workflows/tech_radar.yml @@ -0,0 +1,51 @@ +name: Update Tech Radar + +on: + push: + schedule: + - cron: '0 0 * * *' + +jobs: + update_tech_radar: + runs-on: ubuntu-latest + name: Update Tech Radar + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install gomplate + run: npm install -g gomplate + + - name: Get the list of repositories + id: repository_list + env: + GH_TOKEN: ${{ github.token }} + run: > + echo repository_list_json=$( + gh repo list ${{ github.repository_owner }} \ + --limit 1000 \ + --source \ + --no-archived \ + --visibility public \ + --json name,nameWithOwner,primaryLanguage,url \ + --jq '. | tostring' + ) >> $GITHUB_OUTPUT + + - name: Update the list of used languages + run: ./.github/workflows/techRadar/update_used_languages.sh ${{ toJSON(steps.repository_list.outputs.repository_list_json) }} + + - name: Update the list of used dependencies + env: + GH_TOKEN: ${{ github.token }} + run: ./.github/workflows/techRadar/update_used_dependencies.sh ${{ toJSON(steps.repository_list.outputs.repository_list_json) }} + + - name: Commit the list of changes + run: | + if [ `git ls-files -m | wc -l` -gt 0 ]; then + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add public/techRadar/used_languages.md + git add public/techRadar/used_dependencies.md + git commit -m "Update Tech Radar" + git push + fi diff --git a/public/_sidebar.md b/public/_sidebar.md index ebb0d25..8306ad5 100644 --- a/public/_sidebar.md +++ b/public/_sidebar.md @@ -8,3 +8,8 @@ * [Understanding Licenses](/guides/LICENSE_GUIDE.md) * [Contributor's Handbook](/guides/CONTRIBUTING_GUIDE.md) * [Code of Conduct Guidelines](/guides/CODE_OF_CONDUCT_GUIDE.md) + +**Tech Radar** + +* [Used languages](/techRadar/used_languages.md) +* [Used dependencies](/techRadar/used_dependencies.md) diff --git a/public/techRadar/used_dependencies.md b/public/techRadar/used_dependencies.md new file mode 100644 index 0000000..c17cf4f --- /dev/null +++ b/public/techRadar/used_dependencies.md @@ -0,0 +1,2 @@ +# Used dependencies + diff --git a/public/techRadar/used_languages.md b/public/techRadar/used_languages.md new file mode 100644 index 0000000..701768e --- /dev/null +++ b/public/techRadar/used_languages.md @@ -0,0 +1,6 @@ +# Used languages + +This page lists all the repositories of the SRG SSR GitHub organisation, grouped by primary +language. +Some repository may use more than one language, which is not reflected in this document. + diff --git a/techRadar/used_languages.tmpl b/techRadar/used_languages.tmpl new file mode 100644 index 0000000..ee939e7 --- /dev/null +++ b/techRadar/used_languages.tmpl @@ -0,0 +1,13 @@ +# Used languages + +This page lists all the repositories of the SRG SSR GitHub organisation, grouped by primary +language. +Some repository may use more than one language, which is not reflected in this document. + +{{ range $language, $repositories := (ds "repositories") -}} +## {{ if eq $language "null" }}Unknown{{ else }}{{ $language }}{{ end }} + +{{ range $name, $url := $repositories -}} +- [{{ $name }}]({{ $url }}) +{{ end }} +{{ end -}}