Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload a github action artifact to LATEST release

Tags:

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...

like image 509
AtiqGauri Avatar asked Jul 15 '20 10:07

AtiqGauri


People also ask

Where are GitHub action artifacts stored?

By default, the download-artifact action downloads artifacts to the workspace directory that the step is executing in. You can use the path input parameter to specify a different download directory.

What is upload-artifact?

Upload-Artifact v3 This uploads artifacts from your workflow allowing you to share data between jobs and store data once a workflow is complete. See also download-artifact.

How do I download an artifact from GitHub action?

Under your repository name, click Actions. In the left sidebar, click the workflow you want to see. From the list of workflow runs, click the name of the run to see the workflow run summary. Under Artifacts, click the artifact you want to download.


1 Answers

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 }}
like image 141
Samira Avatar answered Sep 30 '22 01:09

Samira