This action assists you in uploading your asset(s) to your project release page. You are free to choose between using static configuration (with support for variables) and scripted configuration depending on what you need for your project.
Want to upload from your own build server? Yes, it is supported.
When you know up front exactly the files to be uploaded may static configuration be the best choice for your project.
When uploading a single file using parameter file
may you specify all aspects supported by Github. Parameters name
, label
and type
is a reflection of the Github API.
Available parameters:
file
- The file to be uploaded. (Mandatory)name
- Filename when uploaded. Default to the filename offile
.label
- Label replacing filename on release page. Not set unless provided.type
- Content type of your file. Default is to detect using file.
Simple example where the file is uploaded without extra information:
- uses: klakegg/github-upload@v0.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: dist/project.zip
Example where extra information is provided, and where the uploaded filename contains the tag of the build:
- uses: klakegg/github-upload@v0.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: dist/project.zip
name: project-${TAG}.zip
label: Complete project package
type: application/zip
Parameter files
is used to upload multiple files at once. This implementation passes the parameter to ls for discovery of files.
Parameter type
may be used to pass on content type, however other parameters are not supported. Scipted configuration may be an option if you find this too limiting.
Example of uploading zip files made available in a defined folder:
- uses: klakegg/github-upload@v0.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: dist/*.zip
type: application/zip
Scripted configuration may be used when static configuration does not fit your project.
This is an ption where you are free to make whatever logic you want for your upload, and simply call the upload
to perform upload as part of the logic.
Script for handling may be provided inline as part of the workflow definition using the script
parameter, or you may point to a script file using the script_path
parameter.
Example where the script is part of the step definition:
- uses: klakegg/github-upload@v0.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
upload \
-f dist/project.zip \
-n project-${TAG}.zip
Example where script is provided as a file in the repository:
- uses: klakegg/github-upload@v0.9.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script_path: .github/uploads.sh
The upload
command may be used in the script to trigger upload of an asset.
Example of use:
upload \
-f "target/distribution.zip" \
-n "distribution-${TAG}.zip" \
-l "Distribution (zip)" \
-t "application/zip"
Arguments:
-f
- The file to be uploaded. (Mandatory)-n
- Filename when uploaded. Default to the filename offile
.-l
- Label replacing filename on release page. Not set unless provided.-t
- Content type of your file. Default is to detect using file.
The following extra variables are made available during execution:
TAG
- Git tag extracted from the providedGITHUB_REF
, e.g.v1.0
.UPLOAD_URL
- URL used to upload assets.
This project may be used also outside Github Actions to perform upload of assets to Github by using the Docker image used by the action.
The following environment variables need to be provided to make this happen:
GITHUB_REPOSITORY
- Repository where the project may be found, e.g.klakegg/github-upload
.GITHUB_TOKEN
- Token provided by Github to get access.GITHUB_ACTOR
- The owner ofGITHUB_TOKEN
, e.g.klakegg.
GITHUB_REF
orTAG
- Tag reference when usingGITHUB_REF
, e.g.refs/tags/v0.9.1
or simply the tag when usingTAG
, e.g.v0.9.1
.
All parameters and logic are the same as described above, except they have to be passed as environment variables prefixed with INPUT_
and as uppercase. E.g. parameter file
becomes environment variable INPUT_FILE
.