I'm trying to access my GitHub secrets to some .env variables but without effort:
My github secret name:
API_KEY
value:
API_KEY_VALUE
on my .env:
API_KEY=
Extract from my workflow:
name: Laravel
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Copy .env Laravel Configuration for CI
run: php -r "file_exists('.env') || copy('.env.ci', '.env');"
env:
CI: true
API_KEY: ${{ secrets.API_KEY }}
What am I doing wrong?
Turns out I was adding the env: parameters on the wrong task of my steps. I changed then to be where the tests are executed, not where the .env was created:
- name: Execute tests
run: vendor/bin/phpunit
env:
CI: true
API_KEY: ${{ secrets.API_KEY }}