I currently have two GitHub actions workflow files that are pretty much identical, only one is configured to react to push/pull_requests on branch master
the ot
You can drop the global env
statement, combine the event triggers to
on:
push:
branches:
- master
- production
pull_request:
branches:
- master
- production
and then add a first step that checks which branch the workflow is running on and set the environment there:
- name: Set environment for branch
run: |
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "GLCOUD_PROJECT=my-project-stg" >> "$GITHUB_ENV"
echo "VERCEL_TARGET=staging" >> "$GITHUB_ENV"
else
echo "GLCOUD_PROJECT=my-project-prd" >> "$GITHUB_ENV"
echo "VERCEL_TARGET=production" >> "$GITHUB_ENV"
fi