Skip to content

Commit

Permalink
Merge pull request #3 from bvamos/master
Browse files Browse the repository at this point in the history
Optional access token for external repository
  • Loading branch information
dsaltares committed May 16, 2020
2 parents ab444b6 + 131e083 commit e16cc1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The release version to fetch from. Default `"latest"`.

**Required** The name of the file in the release.

### `token`
Optional Personal Access Token to access external repository

## Example usage

```yaml
Expand All @@ -24,4 +27,5 @@ with:
repo: "dsaltares/godot-wild-jam-18"
version: "latest"
file: "plague-linux.zip"
token: ${{ secrets.YOUR_TOKEN }}
```
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
file:
description: 'name of the file in the release to download'
required: true
token:
description: 'optional Personal Access Token to access external repository'
required: false
default: ''

runs:
using: 'docker'
Expand All @@ -21,6 +25,7 @@ runs:
- ${{ inputs.repo }}
- ${{ inputs.version }}
- ${{ inputs.file }}
- ${{ inputs.token }}

branding:
icon: 'download-cloud'
Expand Down
8 changes: 7 additions & 1 deletion fetch_github_asset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ if ! [[ -z ${INPUT_REPO} ]]; then
REPO=$INPUT_REPO ;
fi

API_URL="https://$GITHUB_TOKEN:@api.github.com/repos/$REPO"
# Optional personal access token for external repository
TOKEN=$GITHUB_TOKEN
if ! [[ -z ${INPUT_TOKEN} ]]; then
TOKEN=$INPUT_TOKEN
fi

API_URL="https://$TOKEN:@api.github.com/repos/$REPO"
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 e16cc1f

Please sign in to comment.