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 ...

Created 2020-04-19T07:55:08-07:00 · Edit