|
58 | 58 | required: false |
59 | 59 | default: false |
60 | 60 |
|
| 61 | + # Custom environment variables to inject into the jobs. |
| 62 | + # Expected to be a JSON-formatted string. |
| 63 | + # Example: '{"FIREBASE_APP_CHECK_BRANCH": "nc/target-split"}' |
| 64 | + env_vars: |
| 65 | + type: string |
| 66 | + required: false |
| 67 | + default: "{}" |
| 68 | + |
61 | 69 | outputs: |
62 | 70 | cache_key: |
63 | 71 | description: "The cache key for the Swift package resolution." |
|
72 | 80 | cache_key: ${{ steps.generate_cache_key.outputs.cache_key }} |
73 | 81 | steps: |
74 | 82 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
| 83 | + - name: Set Custom Environment Variables |
| 84 | + run: | |
| 85 | + python3 -c ' |
| 86 | + import os, json |
| 87 | + try: |
| 88 | + env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}")) |
| 89 | + if not isinstance(env_vars, dict): |
| 90 | + raise ValueError("env_vars must be a JSON object") |
| 91 | + with open(os.environ["GITHUB_ENV"], "a") as f: |
| 92 | + for k, v in env_vars.items(): |
| 93 | + f.write(f"{k}={v}\n") |
| 94 | + except json.JSONDecodeError: |
| 95 | + print("Warning: env_vars is not valid JSON. Skipping.") |
| 96 | + except Exception as e: |
| 97 | + print(f"Error setting env vars: {e}") |
| 98 | + ' |
| 99 | + env: |
| 100 | + CUSTOM_ENV_VARS: ${{ inputs.env_vars }} |
75 | 101 | - name: Xcode |
76 | 102 | run: sudo xcode-select -s /Applications/Xcode_26.4.app/Contents/Developer |
77 | 103 | - name: Generate Swift Package.resolved |
@@ -110,6 +136,24 @@ jobs: |
110 | 136 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 |
111 | 137 | with: |
112 | 138 | persist-credentials: false |
| 139 | + - name: Set Custom Environment Variables |
| 140 | + run: | |
| 141 | + python3 -c ' |
| 142 | + import os, json |
| 143 | + try: |
| 144 | + env_vars = json.loads(os.environ.get("CUSTOM_ENV_VARS", "{}")) |
| 145 | + if not isinstance(env_vars, dict): |
| 146 | + raise ValueError("env_vars must be a JSON object") |
| 147 | + with open(os.environ["GITHUB_ENV"], "a") as f: |
| 148 | + for k, v in env_vars.items(): |
| 149 | + f.write(f"{k}={v}\n") |
| 150 | + except json.JSONDecodeError: |
| 151 | + print("Warning: env_vars is not valid JSON. Skipping.") |
| 152 | + except Exception as e: |
| 153 | + print(f"Error setting env vars: {e}") |
| 154 | + ' |
| 155 | + env: |
| 156 | + CUSTOM_ENV_VARS: ${{ inputs.env_vars }} |
113 | 157 | - uses: actions/cache/restore@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 |
114 | 158 | with: |
115 | 159 | path: .build |
|
0 commit comments