Blog
Get Google Cloud Project Id by Name in a GitHub Action Step
, John Comber
Introduction
How to get the Id of a Google Cloud Project from the Project Name then assign it to a PROJECT_ID
environment variable.
Code
- name: Get Project Id
id: get_project_id
run: |-
ID=$(gcloud projects list --filter="NAME='<PROJECT NAME>'" --sort-by=~createTime --limit=1 --format=json | jq -r '.[0].projectId')
echo "PROJECT_ID=$ID" >> $GITHUB_ENV