81 words
1 minute
Set environment variables for all steps in a GitHub Action

Set environment variables for all steps in a GitHub Action#

From this example I learned that you can set environment variables such that they will be available in ALL jobs once at the top of a workflow:

name: Build and Deploy to Cloud Run
on:
push:
branches:
- master
env:
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
RUN_REGION: us-central1
SERVICE_NAME: helloworld-nodejs

I had previously been using this much more verbose pattern:

- name: Fetch projects
env:
BIGLOCAL_TOKEN: ${{ secrets.BIGLOCAL_TOKEN }}
run: python fetch_projects.py dbs/biglocal.db $BIGLOCAL_TOKEN --contact ...
Set environment variables for all steps in a GitHub Action
https://mranv.pages.dev/posts/set-environment-variables-for-all-steps-in-a-github-action/
Author
Anubhav Gain
Published at
2024-08-19
License
CC BY-NC-SA 4.0