How to get GitHub secrets of host repository as input in github action?

2.6k views Asked by At

We have a repository named recent-activity which hosts a GitHub action and is available for use to all GitHub users. We want to add a URL on which we can send http requests when the action is run (by any user). However, we don't want to disclose the URL publicly.

Is there any way this can be done?

2

There are 2 answers

10
GuiFalourd On

You'll find on the official documentation everything you need about Github Secrets

Note that the repository users won't have access to the secret, because you need admin permissions to edit secrets' values. Moreover, secrets won't be shown on the action workflow execution (they will be replaces by *** in logs).

Everyone will use this secret variable in the workflow the same way, without having access to its value.

Demo

Secret output on logs

9
Verma Aman On

You can include secrets from your repo into the workflows directly by specifying their name. Let's say you have a secret named URL then you can simply use it like:

env:
     URL: ${{ secrets.URL }}

Now your URL is fetched and you can use it in other commands like this $URL