From 2a1645ff29a7ca1b769b71a20b727e81c82afae6 Mon Sep 17 00:00:00 2001 From: Julius van Dis Date: Fri, 5 Jan 2024 20:32:04 +0100 Subject: [PATCH] Update to fetch first 3 lines of the readme file --- .github/workflows/list-readmes.yaml | 30 +++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/list-readmes.yaml b/.github/workflows/list-readmes.yaml index 85165bc..accd57a 100644 --- a/.github/workflows/list-readmes.yaml +++ b/.github/workflows/list-readmes.yaml @@ -10,17 +10,23 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v2 + - name: Set up Git credentials + run: echo "machine github.com login ${{ secrets.GITHUB_TOKEN }}" > ~/.netrc - - name: List READMEs + - name: Get organization repositories run: | - # Get a list of repositories in the organization - repos=$(gh api orgs/flock-community/repos --paginate | jq -r '.[].name') - echo "$repos" - - # Loop through each repository and print the first line of its README - for repo in $repos; do - readme_first_line=$(head -n 1 $repo/README.md 2>/dev/null) - echo "$repo: $readme_first_line" - done - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ORG_NAME="flock-community" + REPO_NAME="$(basename "$(pwd)")" + echo "Current repo: $REPO_NAME" + REPOS=$(gh repo list $ORG_NAME --json name -q ".name != '$REPO_NAME'" --limit 1000) + echo "$REPOS" > repos.txt + + - name: List first line of README for each repository + run: | + while IFS= read -r repo; do + REPO_NAME=$(echo $repo | jq -r .name) + echo "Repository: $REPO_NAME + README_FIRST_LINE=$(gh repo view $ORG_NAME/$REPO_NAME --json files -q '.files."README.md".content' | base64 -d | head -n 3) + echo "Repository: $REPO_NAME - First Line of README: $README_FIRST_LINE" + echo "---" + done < repos.txt