Last active
April 15, 2023 23:50
-
-
Save carlos-a-g-h/9ca598a21ea74200aa91f7e5b7d846cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Fetches a github repo | |
GH_TOKEN="$1" | |
GH_REPO_O="$2" | |
GH_REPO_N="$3" | |
GH_REPO_B="$4" | |
OUTDIR="$5" | |
ANAME="$GH_REPO_N.zip" | |
curl \ | |
-H "Accept: */*" \ | |
-H "Authorization: token $GH_TOKEN" \ | |
-L "https://api.github.com/repos/$GH_REPO_O/$GH_REPO_N/zipball/$GH_REPO_B" > "$ANAME" | |
unzip -qq "$ANAME" | |
rm "$ANAME" | |
PATTERN="$GH_REPO_O-$GH_REPO_N" | |
TGT_DIR="$(ls|grep $PATTERN)" | |
mv "$TGT_DIR" "$OUTDIR" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GH_TOKEN="$1" | |
GH_REPO_O="$2" | |
GH_REPO_N="$3" | |
GH_REPO_B="$4" | |
OUTDIR="$5" | |
OUTFILE="$OUTDIR"".zip" | |
curl \ | |
-H "Accept: */*" \ | |
-H "Authorization: token $GH_TOKEN" \ | |
-L "https://api.github.com/repos/$GH_REPO_O/$GH_REPO_N/zipball/$GH_REPO_B" > "$OUTFILE" | |
unzip -qq "$OUTFILE" | |
rm "$OUTFILE" | |
mv "$GH_REPO_O-$GH_REPO_N-"* "$OUTDIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment