Nested Variables in a Variable

I am trying to figure out how to get this NETLIFY_SITE_ID variable working.

    frontend-build:
#      needs: build
      runs-on: ubuntu-18.04
      steps:
      - uses: actions/checkout@v2

    # Deploy the site with netlify-cli
      - name: Deploy Site
        env:
          GITHUB_SHA: ${{ steps.vars.outputs.github_short_sha }}
          NETLIFY_SITE_ID: ${{ format('{0}{1}{2}{3}{4}', '${{ ', 'secrets.', github.event.inputs.lane, '_NETLIFY_SITE_ID', ' }}') }}
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        run: |
          echo $NETLIFY_SITE_ID
          netlify deploy --dir=client/dist --build --prod --message "Deployed from GitHub Action sha $GITHUB_SHA ref ${{ steps.vars.outputs.short_ref }}"

The output in the console looks correct, but it’s not interpreting it as a secret:
netlify

When it works, it should interpret it as a secret and mask the value. I can’t seem to figure it out. Any help would be greatly appreciated. Thanks!

I think it needs to be:

NETLIFY_SITE_ID: ${{ secrets[format('{0}_NETLIFY_SITE_ID', github.event.inputs.lane)] }}
1 Like

Thank you! I was banging my head against a wall on this for so long. I really appreciate it!

1 Like