Github Secret not found in System.getenv

Viewed 987

I've 3 secrets in my Github repo's settings, an action workflow.yml file where:

...
- name: Uploading to Bintray
   env:
     s1: ${{ secrets.SECRET_ONE }}
     s2: ${{ secrets.SECRET_TWO }}
     s3: ${{ secrets.SECRET_THREE }}
   run: ./gradlew bintrayUpload

And my deploy.gradle:

configure<BintrayExtension> {
    var ossPwd = ""
    if (project.rootProject.file("local.properties").exists()) {
        ...
    } else {
        ...
        ossPwd = System.getenv("s3") ?: ""
    }

    pkg.apply {
    ...
        version.apply {
            if (ossPwd.isNotEmpty())
                mavenCentralSync.apply {
                    ...
                    password = ossPwd
            }
        }
    }
}

System.getenv("s3") throws null while SECRET_ONE and SECRET_TWO are fetched correctly.
Any reason why?

EDIT: I've just deleted (for the 10th time) my SECRET_THREE and created another 2 secrets. All 4 were found and correctly used... ¯\_(ツ)_/¯

1 Answers

Considering the GitHub Actions workflow syntax for env, all I can see is:

When more than one environment variable is defined with the same name, GitHub uses the most specific environment variable.

  • an environment variable defined in a step will override job and workflow variables with the same name, while the step executes.
  • A variable defined for a job will override a workflow variable with the same name, while the job executes.

So make sure nothing is overriding SECRET_THREE or s3 itself.


The OP mentions in the comments:

I've just deleted (for the 10th time) my SECRET_THREE and created another 2 secrets.
All 4 were found and correctly used... ¯\_(ツ)_/¯

I've added this:

println("s3"+System.getenv("s3").isNullOrEmpty+\
"s4"+System.getenv("s4").isNullOrEmpty

and it shown s3falses4false and it worked.

Related