Skip to content

Commit 562cb4d

Browse files
committed
Test bblocks-repository-mappings
1 parent 8f4fc4b commit 562cb4d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/validate-and-process.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ on:
8585
sparql_password:
8686
description: SPARQL Graph Store Protocol password for push authentication
8787
required: false
88+
gh_pat:
89+
description: GitHub Personal Access Token to use when cloning repositories
90+
required: false
8891

8992

9093
permissions:
@@ -144,6 +147,44 @@ jobs:
144147
core.exportVariable('PAGES_BASE_URL', base_url);
145148
core.exportVariable('PAGES_PATH', parsed.pathname);
146149
return base_url;
150+
- name: Process GitHub repository mappings
151+
run: |
152+
export RANDOM_DIR="_repos_$(openssl rand -hex 8)"
153+
mkdir "$RANDOM_DIR"
154+
echo '*' > "${RANDOM_DIR}/.gitignore"
155+
156+
if [ -f "bblocks-github.yaml" ]; then
157+
INPUT_YML="bblocks-github.yaml"
158+
elif [ -f "bblocks-github.yml" ]; then
159+
INPUT_YML="bblocks-github.yml"
160+
fi
161+
162+
if [ -z "$INPUT_YML" ]; then
163+
echo "No GitHub repository mappings found"
164+
exit 0
165+
fi
166+
167+
MAPPINGS_YML="bblocks-config-local.yml"
168+
echo 'url-mappings:' > $MAPPINGS_YML
169+
170+
if [ -z "${{ secrets.GH_PAT }}" ]; then
171+
GH_AUTH=
172+
else
173+
GH_AUTH="x-access-token:${{ secrets.GH_PAT }}@"
174+
fi
175+
export GH_AUTH
176+
yq -r '."repository-mappings" | to_entries[] |
177+
"\(strenv(RANDOM_DIR))/\(.value | sub(\"[^A-Za-z0-9]\", \"_\"))" as $SUBDIR |
178+
"
179+
if [ ! -d \"\($SUBDIR)\" ]; then
180+
git clone \"https://\(strenv(GH_AUTH))github.com/\(.value).git\" \"\($SUBDIR)\"
181+
fi
182+
echo \" \\\"\(.key)\\\": \\\"\($SUBDIR)\\\"\" >> bblocks-config-local.yml
183+
"
184+
' < $INPUT_YML | bash
185+
186+
echo "Repositories cloned and mapped in $RANDOM_DIR — output saved to $MAPPINGS_YML"
187+
147188
- name: Before postprocess
148189
if: ${{inputs.before_postprocess}}
149190
run: ${{inputs.before_postprocess}}

0 commit comments

Comments
 (0)