Skip to content

Instantly share code, notes, and snippets.

@carlos-a-g-h
Last active April 15, 2023 23:50
Show Gist options
  • Save carlos-a-g-h/9ca598a21ea74200aa91f7e5b7d846cb to your computer and use it in GitHub Desktop.
Save carlos-a-g-h/9ca598a21ea74200aa91f7e5b7d846cb to your computer and use it in GitHub Desktop.
#!/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"
#!/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