From 1eacc376f9e91dbea9dcba44172ec9a41d0b3d18 Mon Sep 17 00:00:00 2001 From: myadavg Date: Wed, 3 Jun 2026 18:05:13 +0100 Subject: [PATCH 1/3] version3 --- file.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 file.sh diff --git a/file.sh b/file.sh new file mode 100644 index 00000000..ef427dd9 --- /dev/null +++ b/file.sh @@ -0,0 +1,50 @@ +#!/bin/bash +################################ +# Author: Abhishek +# Version: v1 +# +# +# +# This script will help users to communicate and retrieve information from GitHub +# Usage: +# Please provide your github token and rest api to the script as input +# +# +################################ + +if [ ${#@} -lt 2 ]; then + echo "usage: $0 [your github token] [REST expression]" + exit 1; +fi + +GITHUB_TOKEN=$1 +GITHUB_API_REST=$2 + +GITHUB_API_HEADER_ACCEPT="Accept: application/vnd.github.v3+json" + +temp=`basename $0` +TMPFILE=`mktemp /tmp/${temp}.XXXXXX` || exit 1 + + +function rest_call { + curl -s $1 -H "${GITHUB_API_HEADER_ACCEPT}" -H "Authorization: token $GITHUB_TOKEN" >> $TMPFILE +} + +# single page result-s (no pagination), have no Link: section, the grep result is empty +last_page=`curl -s -I "https://api.github.com${GITHUB_API_REST}" -H "${GITHUB_API_HEADER_ACCEPT}" -H "Authorization: token $GITHUB_TOKEN" | grep '^Link:' | sed -e 's/^Link:.*page=//g' -e 's/>.*$//g'` + +# does this result use pagination? +if [ -z "$last_page" ]; then + # no - this result has only one page + rest_call "https://api.github.com${GITHUB_API_REST}" +else + + # yes - this result is on multiple pages + for p in `seq 1 $last_page`; do + rest_call "https://api.github.com${GITHUB_API_REST}?page=$p" + done +fi + +cat $TMPFILE + + From 294b57af7d78f6d5bf7e6f05c2f8477eb1400e5e Mon Sep 17 00:00:00 2001 From: myadavg Date: Wed, 3 Jun 2026 18:23:46 +0100 Subject: [PATCH 2/3] update version3 --- file.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/file.sh b/file.sh index ef427dd9..f0958e77 100644 --- a/file.sh +++ b/file.sh @@ -7,6 +7,7 @@ # # This script will help users to communicate and retrieve information from GitHub # Usage: +# # Please provide your github token and rest api to the script as input # # From c9fc2ec5b07c7952b8579328523bed3419dbc512 Mon Sep 17 00:00:00 2001 From: myadavg Date: Wed, 3 Jun 2026 18:44:31 +0100 Subject: [PATCH 3/3] version2 updated --- github-api-integration-module.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/github-api-integration-module.sh b/github-api-integration-module.sh index d94d2951..a97e2f09 100644 --- a/github-api-integration-module.sh +++ b/github-api-integration-module.sh @@ -10,6 +10,7 @@ # Please provide your github token and rest api to the script as input # # +# ################################ if [ ${#@} -lt 2 ]; then