diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 34e8d0f29ed..f6965e026f8 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -40,6 +40,14 @@ on: type: number default: 3 + # Custom environment variables to inject into the jobs. + # Expected to be a JSON-formatted string. + # Example: '{"FIREBASE_APP_CHECK_BRANCH": "nc/target-split"}' + env_vars: + type: string + required: false + default: "{}" + # IMPORTANT: When adding new secrets to this workflow, update the # 'has_secrets' logic in the 'check_secrets' job to include the new secret. secrets: @@ -96,6 +104,24 @@ jobs: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false + - name: Set Custom Environment Variables + run: | + python3 -c ' + import os, json + try: + env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}")) + if not isinstance(env_vars, dict): + raise ValueError("env_vars must be a JSON object") + with open(os.environ["GITHUB_ENV"], "a") as file: + for key, value in env_vars.items(): + file.write(f"{key}={value}\n") + except json.JSONDecodeError: + print("Warning: env_vars is not valid JSON. Skipping.") + except Exception as error: + print(f"Error setting env vars: {error}") + ' + env: + CUSTOM_ENV_VARS: ${{ inputs.env_vars }} - uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1 if: inputs.method != 'spm' && inputs.method != 'spmbuildonly' && inputs.method != 'cmake' - name: Setup Bundler