Home > Blockchain >  Adding an asset to a release through GitHub action triggered on release creation
Adding an asset to a release through GitHub action triggered on release creation

Time:01-30

We have a GitHub Actions workflow triggered by the creation of a release, i.e.,

on:
  release:
    types: [created]

How can we add the built files to the triggereing release as an asset from within the workflow?

I have seen this answer recommending softprops/action-gh-release, but that seems to apply to workflows triggered by pushes (with tags) and not "on release".

CodePudding user response:

You can use the same action with the on: release trigger.

The GITHUB_REF environment variable or GitHub.ref context variable should contain the tag of the release.

See:

Another way to add files to the workflow is to use the GitHub CLI:

gh release upload $GITHUB_REF path/to/file path/to/file etc

That way you don't need to pull in actions from the marketplace.

${{ github.event.release.tag_name }}

Is another way to access the tag name.

  • Related