Github actions environment variable

Hello, we have a project running on fly which was deployed from local development now we are moving to using Github action but we are having issue with loading environment variable which was added to Github secrets.

When are deploying from local development all of our environmental variables are added to fly.toml in env section.

Currently, the deployment from Github action is failing because it cant get the secret from Github

name: Fly Deploy
on: [push]
env:
  FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
  DATABASE_URL: ${{ secrets.DATABASE_URL }}
  FUSION_AUTH_API_KEY: ${{ secrets.FUSION_AUTH_API_KEY }}
  FUSION_AUTH_APP_ID: ${{ secrets.FUSION_AUTH_APP_ID }}
  FUSION_AUTH_PUBLIC_KEY: ${{ secrets.FUSION_AUTH_PUBLIC_KEY }}
  FUSION_AUTH_URL: ${{ secrets.FUSION_AUTH_URL }}
jobs:
  deploy:
    name: Deploy app
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: superfly/flyctl-actions/setup-flyctl@master
      - run: echo "FUSION_AUTH_URL $FUSION_AUTH_URL"
      - run: echo "FLY_API_TOKEN $FLY_API_TOKEN"
      - run: flyctl deploy
             --build-secret FUSION_AUTH_URL=$FUSION_AUTH_URL
            --remote-only

Am getting an error that it can’t find the variable.
What is the best way to add multiple (up to 20) environment variables to fly env?

@kurt Is it possible to load the variable in fly.toml file ?

Ref: Best practice for build-time secrets? - #6 by rubys

Not sure why, but I will say that your yaml looks okay to me. We use workflow-level env vars with the env. context (code), instead (no reason why the way you did wouldn’t work).

  flyctl deploy
        --image-label ${{ env.GIT_HEAD }}
        --config ${{ env.FLY_TOML }}
        --strategy ${{ env.FLY_DEPLOY_STRAT }}
        --verbose

(not kurt)

Yes, in the [env] section of the toml for runtime env vars (docs).

For build-time secrets refer: RAILS_MASTER_KEY environment variable not getting fetched - #2 by ignoramous

See also fly secrets set: How to include `fly-log-shipper` in a project? - #2 by ignoramous