Davis
Davis

Reputation: 508

Github Actions environment variables not being set on Linux

I'm trying to set my Github secrets as env variables via Actions but for some reasons they aren't being set (Using Ubuntu 22.04.1 LTS).

name: My app

on:
  push:
    branches: [ "main" ]

env:
  JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
  JWT_REFRESH_SECRET: ${{ secrets.JWT_REFRESH_SECRET }}
  MONGO_CONNECTION_STRING: ${{ secrets.MONGO_CONNECTION_STRING }}
  PLAI_APP_URL: ${{ secrets.APP_URL }}
  SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}

permissions:
  contents: read

jobs:
  build:

    runs-on: self-hosted

    steps:
    - name: check out latest repo
      uses: actions/checkout@v3
      with:
        ref: main
    - name: Set up Python 3.10
      uses: actions/setup-python@v3
      with:
        python-version: "3.10"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -r requirements.txt

Workflow runs successfully without errors but when I check my variables via env they are not listed. Any idea what I'm doing wrong?

Upvotes: 1

Views: 740

Answers (1)

VonC
VonC

Reputation: 1328282

You could follow the same idea as in "Managing secrets in an open-sourced flutter web app" from Mahesh Jamdade:

  1. encode your confidential file to base64 and store the encoded output to GitHub secrets.
  2. In your GitHub workflow decode the encrypted secret and convert it back to a file and then run your build scripts.

You can see an example in "How to access secrets when using flutter web with github actions".
Example workflow: maheshmnj/vocabhub .github/workflows/firebase-hosting-merge.yml.

Upvotes: 1

Related Questions