add gitlab wiki scrape

master
Bel LaPointe 2022-01-31 15:50:23 -07:00
parent 94fbde9cad
commit 8aa8b979f1
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#! /bin/bash
GITLAB_PAT="$GITLAB_PAT"
PROJECT="$PROJECT"
BLOB="$BLOB"
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}
project="$(urlencode $PROJECT)"
blob="$(urlencode $BLOB)"
path="api/v4/projects/$project/wikis/$blob"
curl -sS -H "Authorization: Bearer $GITLAB_PAT" "https://gitlab-app.eng.qops.net/$path" | jq -r .content