How do I inject environment variables and secrets into Github action pipeline using config.json

2.2k Views Asked by At

How do I inject secrets and environment variables residing in my config.json to GitHub action in nodejs?

For instance

{
   apiKey: "blablabla",
   apiId: "anotherblabla"
}
1

There are 1 best solutions below

0
On

Use github CLI and you get many options on how to inject secrets:

Paste secret value for the current repository in an interactive prompt

$ gh secret set MYSECRET

Read secret value from an environment variable

$ gh secret set MYSECRET --body "$ENV_VALUE"

Read secret value from a file

$ gh secret set MYSECRET < myfile.txt

Set secret for a deployment environment in the current repository

$ gh secret set MYSECRET --env myenvironment

Set organization-level secret visible to both public and private repositories

$ gh secret set MYSECRET --org myOrg --visibility all

Set organization-level secret visible to specific repositories

$ gh secret set MYSECRET --org myOrg --repos repo1,repo2,repo3

Set user-level secret for Codespaces

$ gh secret set MYSECRET --user

Set repository-level secret for Dependabot

$ gh secret set MYSECRET --app dependabot

Set multiple secrets imported from the ".env" file

$ gh secret set -f .env