最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to set Laravel env variable through Github Actions - Stack Overflow

programmeradmin2浏览0评论

Basically I have a Laravel application which uses google/cloud-vision package. Also using Laravel Vapor for deployment.

I'm trying to setup Github Actions. I'm using for google authentication. As per the document I added below lines to the deploy.yml file

The documentation mentioned it exports environment variable GOOGLE_APPLICATION_CREDENTIALS

How can I make the env GOOGLE_APPLICATION_CREDENTIALS available in Laravel application ?

I also tried below one but when I fetch env('GOOGLE_APPLICATION_CREDENTIALS') it returns null.

Basically I have a Laravel application which uses google/cloud-vision package. Also using Laravel Vapor for deployment.

I'm trying to setup Github Actions. I'm using https://github/google-github-actions/auth for google authentication. As per the document I added below lines to the deploy.yml file

The documentation mentioned it exports environment variable GOOGLE_APPLICATION_CREDENTIALS

How can I make the env GOOGLE_APPLICATION_CREDENTIALS available in Laravel application ?

I also tried below one but when I fetch env('GOOGLE_APPLICATION_CREDENTIALS') it returns null.

Share Improve this question asked Mar 14 at 16:33 Saumini NavaratnamSaumini Navaratnam 8,8905 gold badges46 silver badges74 bronze badges 4
  • And what is the error? What you have done on the last image (using env:) is the way of sharing any env('xxxx') onto any command you are running using run: – matiaslauriti Commented Mar 14 at 16:52
  • There is no error, when I fetch the env env('GOOGLE_APPLICATION_CREDENTIALS') it returns null. So I believe the env variable is not setting. I also tried adding a simple env like HELLO: 'WORLD' and try to access in the application & it returns null. – Saumini Navaratnam Commented Mar 14 at 17:08
  • You have to show us how you are doing that, if you are running php artisan optimize or php artisan config:cache, then env will always return null anywhere, it must be done inside a config file for this to not happen, can you make sure to add env('GOOGLE_APPLICATION_CREDENTIALS', 123) so we just see if 123 is there or what is going on? Where are you using the env? – matiaslauriti Commented Mar 14 at 18:08
  • Hey I'm not running config:cache explicitly, unless Laravel Vapor runs. For env('GOOGLE_APPLICATION_CREDENTIALS', 123) it prints 123. I'm printing the env in the controller. What do you like to see more, the deploy.yml file or the vapor.yml file ? – Saumini Navaratnam Commented Mar 17 at 21:50
Add a comment  | 

1 Answer 1

Reset to default 0

The google-github-actions/auth action only exports GOOGLE_APPLICATION_CREDENTIALS if create_credentials_file is explicitly set to true. Modify your deploy.yml to include this:

- id: google-auth
  name: Google Auth
  uses: google-github-actions/auth@v2
  with:
    credentials_json: '${{ secrets.GOOGLE_API_CREDENTIALS }}'
    create_credentials_file: true
发布评论

评论列表(0)

  1. 暂无评论