Skip to content

Commit

Permalink
default to the current repo
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaltares committed Feb 25, 2020
1 parent 6f8eb79 commit 8cb83a3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This action downloads an asset from a Github release. Private repos are supporte

### `repo`

**Required** The `org/repo`.
The `org/repo`. Defaults to the current repo.

### `version`

Expand Down
3 changes: 2 additions & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description: 'Downloads an asset from a Github release'
inputs:
repo:
description: 'org/repo to download from'
required: true
required: false
default: ''
version:
description: 'version of the release to download from'
required: false
Expand Down
23 changes: 18 additions & 5 deletions fetch_github_asset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,30 @@ if [[ -z "$GITHUB_TOKEN" ]]; then
exit 1
fi

if [[ -z "$INPUT_REPO" ]]; then
echo "Missing repo input in the action"
if [[ -z "$INPUT_FILE" ]]; then
echo "Missing file input in the action"
exit 1
fi

if [[ -z "$INPUT_FILE" ]]; then
echo "Missing file input in the action"
if [[ -z "$GITHUB_REPOSITORY" ]]; then
echo "Missing GITHUB_REPOSITORY env variable"
exit 1
fi

API_URL="https://$GITHUB_TOKEN:@api.github.com/repos/$INPUT_REPO"
REPO=$GITHUB_REPOSITORY
if ! [[ -z ${INPUT_REPO} ]]; then
REPO=$INPUT_REPO ;
fi

echo $GITHUB_REPOSITORY
echo $INPUT_REPO
echo $REPO

API_URL="https://$GITHUB_TOKEN:@api.github.com/repos/$GITHUB_REPOSITORY"

echo $API_URL
echo $INPUT_VERSION

ASSET_ID=$(curl $API_URL/releases/${INPUT_VERSION} | jq -r ".assets | map(select(.name == \"${INPUT_FILE}\"))[0].id")

if [[ -z "$ASSET_ID" ]]; then
Expand Down

0 comments on commit 8cb83a3

Please sign in to comment.