GitHub Action
kubevela-action-upload-release-asset
The action wraps the GitHub Release API, specifically the Upload A Release Asset endpoint, to allow you to leverage GitHub Actions to upload release assets.
Create a workflow .yml
file in your repositories .github/workflows
directory. For more information, reference the GitHub Help Documentation for Quickstart for GitHub Actions. You also will need to have a release to upload your asset to, which could be created programmatically by @bruceadams/get-release
as show in the example workflow.
This Action needs the environment variable ${{ secrets.GITHUB_TOKEN }}
to be set correctly.
GITHUB_TOKEN
secret created automatically by GitHub, and you don't need more operation. For more information, see the Automatic token authentication
For more information on these inputs, see the API Documentation
release_id
: The ID uploading assets to the release, which could come from another GitHub Action, for example the@bruceadams/get-release
GitHub Action
For more information on these outputs, see the API Documentation
id
: The ID of the assetbrowser_download_url
: The URL users can navigate to in order to download the release asset.
On every push
to a tag matching the pattern v*
, create a release and upload a release asset. This Workflow example assumes you have the @bruceadams/get-release
Action in a previous step:
name: Upload Release Asset
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build project # This would actually build your project, using zip for an example artifact
run: |
zip --junk-paths my-artifact README.md
- name: Get Release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
id: upload-release-asset
uses: basefas/upload-release-asset-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.get_release.outputs.id }} # This pulls from the Get RELEASE step above, referencing its ID to get its outputs object, which include a `id`.
asset_path: ./my-artifact.zip
asset_name: my-artifact.zip
This will upload a release artifact to an existing release, outputting the browser_download_url
for the asset which could be handled by a third party service, or by GitHub Actions for additional uses. For more information, see the GitHub Documentation for the upload a release asset endpoint.
The scripts and documentation in this project are released under the MIT License