How do I access GitHub Actions Environment Secrets?

Viewed 623

Pretty simple problem, I am not sure what I am missing.

I have an environment secret:

enter image description here

In this case, the "production" environment is available to all branches. I am simply trying to access the MESSAGE variable in my appsettings replacement action (I have tried adding and removing the repo level MESSAGE to no avail):

- uses: actions/checkout@master
- name: Variable Substitution
  uses: microsoft/variable-substitution@v1
  with:
    files: DummyApi/appsettings.json
  env:
    Message: ${{ secrets.MESSAGE }}

This will replace it with the repo level setting, but not the env level setting, this does not replace it at all:

- uses: actions/checkout@master
- name: Variable Substitution
  uses: microsoft/variable-substitution@v1
  with:
    files: DummyApi/appsettings.json
  env:
    Message: ${{ env.MESSAGE }}

Simply - how do I access the MESSAGE value in an environment? Do I need to set an environment manually or something? Thank you.

ADDED INFO:

What I really want to do is something like this:

on: [push]
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    environment: contains('main', $GITHUB_REF) ? production : development

I know that last line will not work, but it seems if I set the environment, I can see the secrets - I would just like to reuse a lot of the deploy code instead of copy/paste.

0 Answers
Related