|
85 | 85 | sparql_password: |
86 | 86 | description: SPARQL Graph Store Protocol password for push authentication |
87 | 87 | required: false |
| 88 | + gh_pat: |
| 89 | + description: GitHub Personal Access Token to use when cloning repositories |
| 90 | + required: false |
88 | 91 |
|
89 | 92 |
|
90 | 93 | permissions: |
@@ -144,6 +147,44 @@ jobs: |
144 | 147 | core.exportVariable('PAGES_BASE_URL', base_url); |
145 | 148 | core.exportVariable('PAGES_PATH', parsed.pathname); |
146 | 149 | 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 | +
|
147 | 188 | - name: Before postprocess |
148 | 189 | if: ${{inputs.before_postprocess}} |
149 | 190 | run: ${{inputs.before_postprocess}} |
|
0 commit comments