Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting artifact upload public URL in steps after upload #30

Open
AaronMT opened this issue May 20, 2021 · 5 comments
Open

Getting artifact upload public URL in steps after upload #30

AaronMT opened this issue May 20, 2021 · 5 comments

Comments

@AaronMT
Copy link

AaronMT commented May 20, 2021

Hello,

In a GitHub Actions job, after google-github-actions/upload-cloud-storage@main step, I would like to get the public URL of the uploaded artifact from the previous step.

The idea is a job using the following steps as an example:

  • Build a binary
  • Upload binary as an artifact
  • Fire off a Slack message with a public URL of said binary

How would you get the public URL of the artifact in a subsequent step?

- uses: google-github-actions/upload-cloud-storage@main
   name: Upload Artifact (json) to Google Cloud Storage
   with: 
       path: file
       destination:  bucket/output
       env-pub: FOOBAR
  -name: Use URL for something
    run: echo "${{ env.FOOBAR }}"

The last command would give me a public URL to the uploaded artifact.

@jakub-bacic
Copy link
Contributor

jakub-bacic commented Jul 17, 2021

That should do the trick:

steps:
  - id: upload-file
    name: Upload Artifact (json) to Google Cloud Storage
    uses: google-github-actions/upload-cloud-storage@main
    with:
      path: file
      destination:  bucket/output

  - name: Get public URL
    run: echo "PUBLIC_URL=https://storage.googleapis.com/${{ steps.upload-file.outputs.uploaded }}" | sed 's|gs://||' >> $GITHUB_ENV

  - name: Use URL for something
    run: echo "${{ env.PUBLIC_URL }}"

@bharathkkb
Copy link
Contributor

Hi @AaronMT does the workaround provided by @jakub-bacic (thanks!) work for you or were you looking for something else like a signed url?

@AaronMT
Copy link
Author

AaronMT commented Aug 18, 2021

I haven't had a chance to try it yet, but that looks like what I was looking for albeit as a workaround.

@RuiGamitoFRVR
Copy link

RuiGamitoFRVR commented Feb 23, 2022

Was also looking for something like this.
The workaround works for me, apart from some minor details, particularly because I'm uploading a single file - otherwise it would involve iterating through the CSV list of files returned by ${{ steps.upload-file.outputs.uploaded }}.
Also, might be worth noting that the pipe to sed 's|gs://||' doesn't seem to be relevant anymore as the prefix and bucket are no longer returned. Since the bucket is not returned, that needs to be added when creating either the download link or the GS URI.

@dragos-panzaru-md
Copy link

I am trying to achieve something similar, by copying artefacts from inside a docker container to the actual github runner on which the container run, and then try to upload these artefacts to google cloud. However, this works only if all tests in my suite pass, but if I have a failures then it gives the following error: google-github-actions/upload-cloud-storage failed with: ENOENT: no such file or directory, lstat '<path/to/test/report>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants