From ebad482d6ae9eaebab377ce367c474bce54de967 Mon Sep 17 00:00:00 2001 From: gaudinnicolas Date: Wed, 14 Feb 2024 11:05:43 +0100 Subject: [PATCH] Fix: d4g-utils action for test --- .github/workflows/d4g-utils.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/d4g-utils.yml b/.github/workflows/d4g-utils.yml index 80a1339..bf0815c 100644 --- a/.github/workflows/d4g-utils.yml +++ b/.github/workflows/d4g-utils.yml @@ -3,7 +3,7 @@ name: Copy File to Organization Repos on: push: paths: - - 'd4g-utils/**' # Trigger the workflow only when changes are made in the d4g-utilsdirectory + - 'd4g-utils/**' # Trigger the workflow only when changes are made in the d4g-utils directory branches: - main @@ -30,17 +30,25 @@ jobs: TOKEN=$1 # Fetch repositories from the organization - response=$(curl -s -H "Authorization: Bearer $TOKEN" "https://api.github.com/orgs/$ORG_NAME/repos") + repos=`gh repo list $ORG_NAME --limit 500 | awk ' {print $1}'` - # Extract repository names created from the template - repos=$(echo "$response" | jq -r ".[] | select(.template_repository.full_name == \"$TEMPLATE_REPO\") | .full_name") - echo "::set-output name=repos::$repos" env: GITHUB_TOKEN: ${{ secrets.D4GTECH_TOKEN }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # - name: Copy files to organization repos - # run: | + - name: Copy files to organization repos + run: | + echo "Searching for repositories generated from template: $template_repo" + for repo in ${{ steps.org_repos.outputs.repos }}; do + repo_info=`gh api repos/$repo` + echo "$repo_info" | jq -r ".template_repository.full_name" | grep "$template_repo" 2>&1 > /dev/null + if [ "$?" -eq "0" ] + then + echo "repo_using_template: $repo" + fi + done + # for repo in ${{ steps.org_repos.outputs.repos }}; do # # Clone the repository # git clone "https://github.com/$repo" target_repo