0

I'm trying to access GitHub SECRETS and VARIABLES set at the Repo level and at the Organization level for a GitHub "Actions" script.

Here is the script:

name: CI (pip)
on: [push, pull_request]

jobs:
  build:
    strategy:
      matrix:
        os: ['ubuntu-latest']
        python-version: [3.9]   # installed version on Dreamhost
    runs-on: ${{ matrix.os }}
    timeout-minutes: 10
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: true

      - name: First Test
        run: |
          echo ORG_NAME   = ${{ env.ORG_NAME}}
          echo MY_NAME    = ${{ env.MY_NAME}}
          echo MY_SECRET  = ${{ secrets.MY_SECRET }}

      - name: Second Test
        env:
          ORG_NAME_ENV:        ${{ env.ORG_NAME }}
          MY_NAME_ENV:         ${{ env.MY_NAME }}
          MY_SECRET:           ${{ secrets.MY_SECRET }}
        run: |
          echo ORG_NAME_ENV = $ORG_NAME_ENV
          echo MY_SECRET = $MY_SECRET
          echo SHA256 = `echo $MY_SECRET | openssl sha256`

This just doesn't work. The secrets.MY_SECRET gets set, but env.ORG_NAME and env.MY_NAME do not get set.

Here is what the config looks like:

Organization level actions secrets and variables: enter image description here

Repo secrets:

enter image description here

Repo level variables:

enter image description here

I can access the secrets, but not the variables.

Here is what the output looks like:

enter image description here

Oh, MY_SECRET=secret, in case you don't want to do the hash search.

vy32
  • 28,461
  • 37
  • 122
  • 246

1 Answers1

1

Configuration variables are accessed via the vars context, not env.

See:

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
  • Thank you so much. This was surprisingly hard for me to find using the GitHub documentation and with a lot of work with Google. – vy32 Aug 06 '23 at 14:33