AButler / upload-release-assets

GitHub Action to upload assets to a Release
MIT License
59 stars 20 forks source link

Cannot read properties of undefined #42

Open hirrolot opened 5 months ago

hirrolot commented 5 months ago

Uploading any file, for example as follows:


jobs:
  build:
    steps:
      - uses: AButler/upload-release-assets@v3.0
        with:
          files: "my_file.txt"
          repo-token: ${{ secrets.GITHUB_TOKEN }}

leads to the following error:

Error: Cannot read properties of undefined (reading 'id')
EchoEllet commented 4 months ago

I had the same issue, you can fix it by explicitly passing a value to release-tag:

      - name: ⬆️ Upload the assets
        uses: AButler/upload-release-assets@v3.0
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          files: "dist/*;LICENSE"
          release-tag: ${{ github.ref_name }}

It's also possible to fix it using release-id, you will need to send an HTTP GET request to GitHub Public API and parse the JSON response though.

The fallback of this action may work differently depending on the workflow and might not work with the configurations you and I have.

Also, make sure to have contents write permission:

jobs:
  publish:
    permissions:
      contents: write