Reputation: 1615
I want to upload a artifact to latest release... without creating a new release.
I started with github official action upload-release-asset to upload artifact.
It requires a upload_url as an input which tells it the url of release.
Which is generally taken from creating a release in previous step with create-release action.
I tried to print output url from create_release-
https://uploads.github.com/repos/atiqg/test/releases/28579698/assets{?name,label}
Then I changed it to direct to latest release-
https://uploads.github.com/repos/atiqg/test/releases/latest/assets
Which oblivously did not work out and thrown this error-
##[error]Multipart form data required
Is there any way I can do this? I don't want to create a new release from actions.
I want to create release normally then action should upload artifact to latest release...
Upvotes: 7
Views: 2853
Reputation: 9761
If latest
doesn't work, you can use GitHub API to get upload_url
...
https://api.github.com/repos/actions/checkout/releases/latest
...and then pass it to upload-release-asset
.
In workflow it would look something like this
- run: |
upload_url=$(curl -sL https://api.github.com/repos/actions/checkout/releases/latest | jq -r '.upload_url')
echo UPLOAD_URL=$upload_url >> $GITHUB_ENV
shell: bash
- uses: actions/upload-release-asset@v1
with:
upload_url: ${{ env.UPLOAD_URL }}
Upvotes: 5