-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk add --no-cache \ | ||
curl \ | ||
jq | ||
|
||
COPY fetch_github_asset.sh /fetch_github_asset.sh | ||
|
||
ENTRYPOINT ["/fetch_github_asset.sh"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
# fetch-gh-release-asset | ||
Github Action to download an asset from a Github release | ||
# Fetch GH Release Asset | ||
|
||
This action downloads an asset from a Github release. Private repos are supported. | ||
|
||
## Inputs | ||
|
||
### `repo` | ||
|
||
**Required** The `org/repo`. | ||
|
||
### `version` | ||
|
||
The release version to fetch from. Default `"latest"`. | ||
|
||
### `file` | ||
|
||
**Required** The name of the file in the release. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: dsaltares/fetch-gh-release-asset@master | ||
with: | ||
repo: "dsaltares/godot-wild-jam-18" | ||
version: "latest" | ||
file: "plague-linux.zip" | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: 'Fetch Github Release Asset' | ||
description: 'Downloads an asset from a Github release' | ||
|
||
inputs: | ||
repo: | ||
description: 'org/repo to download from' | ||
required: true | ||
version: | ||
description: 'version of the release to download from' | ||
required: false | ||
default: 'latest' | ||
file: | ||
description: 'name of the file in the release to download' | ||
required: true | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.repo }} | ||
- ${{ inputs.version }} | ||
- ${{ inputs.file }} | ||
|
||
branding: | ||
icon: 'download-cloud' | ||
color: 'orange' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
if [[ -z "$GITHUB_TOKEN" ]]; then | ||
echo "Missing GITHUB_TOKEN env variable" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$INPUT_REPO" ]]; then | ||
echo "Missing repo input in the action" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$INPUT_FILE" ]]; then | ||
echo "Missing file input in the action" | ||
exit 1 | ||
fi | ||
|
||
API_URL="https://$GITHUB_TOKEN:@api.github.com/repos/$INPUT_REPO" | ||
ASSET_ID=$(curl $API_URL/releases/${INPUT_VERSION} | jq -r ".assets | map(select(.name == \"${INPUT_FILE}\"))[0].id") | ||
|
||
if [[ -z "$ASSET_ID" ]]; then | ||
echo "Could not find asset id" | ||
exit 1 | ||
fi | ||
|
||
curl \ | ||
-J \ | ||
-L \ | ||
-H "Accept: application/octet-stream" \ | ||
"$API_URL/releases/assets/$ASSET_ID" \ | ||
-o ${INPUT_FILE} |