Skip to content

Commit 277d6a5

Browse files
committed
Add possibility to sertup .env in VARIABLES of Github
1 parent 4cc5dd3 commit 277d6a5

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/deploy.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ jobs:
4040
printf '%s\n' "${{ secrets.MESH_SECRETS_STAGE }}"
4141
printf '%s\n' '__MESH_SECRETS__'
4242
} >> "$GITHUB_ENV"
43+
if [ -n "${{ vars.ENV_STAGE }}" ]; then
44+
{
45+
printf '%s\n' 'AIO_ENV_FILE<<__AIO_ENV_FILE__'
46+
printf '%s\n' "${{ vars.ENV_STAGE }}"
47+
printf '%s\n' '__AIO_ENV_FILE__'
48+
} >> "$GITHUB_ENV"
49+
fi
4350
elif [ "$BRANCH_NAME" = "production" ]; then
4451
echo "TARGET_ENV=production" >> "$GITHUB_ENV"
4552
echo "CLIENTID=${{ secrets.CLIENTID_PROD }}" >> "$GITHUB_ENV"
@@ -52,6 +59,13 @@ jobs:
5259
printf '%s\n' "${{ secrets.MESH_SECRETS_PROD }}"
5360
printf '%s\n' '__MESH_SECRETS__'
5461
} >> "$GITHUB_ENV"
62+
if [ -n "${{ vars.ENV_PROD }}" ]; then
63+
{
64+
printf '%s\n' 'AIO_ENV_FILE<<__AIO_ENV_FILE__'
65+
printf '%s\n' "${{ vars.ENV_PROD }}"
66+
printf '%s\n' '__AIO_ENV_FILE__'
67+
} >> "$GITHUB_ENV"
68+
fi
5569
else
5670
echo "Unsupported branch '$BRANCH_NAME'. Only staging and production are allowed." >&2
5771
exit 1
@@ -81,6 +95,12 @@ jobs:
8195
set -euo pipefail
8296
printf '%s\n' "$MESH_SECRETS" > secrets.yaml
8397
chmod 600 secrets.yaml
98+
- name: Materialize branch .env file
99+
if: ${{ env.AIO_ENV_FILE != '' }}
100+
run: |
101+
set -euo pipefail
102+
printf '%s\n' "$AIO_ENV_FILE" > .env
103+
chmod 600 .env
84104
- name: Setup CLI
85105
uses: adobe/aio-cli-setup-action@1.3.0
86106
with:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to this project will be documented in this file. The format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the repository uses [Semantic Versioning](https://semver.org/).
44

5+
## [1.1.1] - 2025-12-04
6+
### Added
7+
- Workflow now consumes GitHub repository variables `ENV_STAGE` / `ENV_PROD`, writes their full multi-line contents into `.env`, and feeds that file to the Adobe API Mesh CLI before create/update operations.
8+
- Documentation updates explaining the new `.env` injection path and the recommended GitHub variables for environment-specific configuration.
9+
510
## [1.1.0] - 2025-11-25
611
### Added
712
- New primary workflow `.github/workflows/deploy.yaml` that materializes branch-specific mesh secrets, computes CLI flags automatically, and waits for mesh provisioning with retry logic.

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This repository is a lightweight starting point for teams that want a repeatable
1313

1414
### Key Capabilities
1515

16+
- **Dynamic `.env` injection** – GitHub repository variables (`ENV_STAGE`, `ENV_PROD`) can store full `.env` payloads, and the workflow materializes them into a runtime `.env` before invoking the API Mesh CLI.
1617
- **Secret materialization** – branch-specific secrets can include encrypted mesh credentials (`MESH_SECRETS_*`) that the workflow writes to `secrets.yaml` on the fly and passes through `--secrets` so sensitive resolvers stay out of Git history.
1718
- **Auto-flag builder** – the workflow inspects the repo for `.env` and `secrets.yaml` and automatically appends the correct `aio api-mesh:*` flags, helping you wire runtime configuration consistently.
1819
- **Provisioning watchdog** – mesh deployments poll `aio api-mesh:status` for up to 10 minutes with friendly logging, failing early if provisioning stalls or ends unexpectedly.
@@ -57,6 +58,15 @@ Configure the following secrets under **Settings → Secrets and variables → A
5758

5859
Add any extra secrets referenced by your mesh (for custom resolvers, HTTP headers, etc.) and load them via environment variables or additional steps in the workflow.
5960

61+
### Recommended GitHub Variables
62+
63+
| Variable Name | When Used | Description |
64+
| --- | --- | --- |
65+
| `ENV_STAGE` | Pushes to `staging` | Full contents of the `.env` file you want the staging deployment to consume (multi-line values supported). |
66+
| `ENV_PROD` | Pushes to `production` | Production `.env` payload, typically mirroring secure resolver configuration for production meshes. |
67+
68+
If these variables are present, the workflow writes them to `.env` before running `aio api-mesh:*`. If they are empty, the pipeline falls back to any `.env` file committed in the repository or skips the flag entirely.
69+
6070
---
6171

6272
## Quick Start
@@ -65,7 +75,7 @@ Add any extra secrets referenced by your mesh (for custom resolvers, HTTP header
6575
2. **Add your mesh files**:
6676
- Place the primary mesh definition in `mesh.json`.
6777
- Commit any supporting schemas/resolvers alongside it.
68-
- (Optional) store non-secret runtime values in `.env` (e.g., `MESH_NAME=my-mesh`). The workflow passes `--env .env` to the CLI so those values are merged during create/update.
78+
- Provide runtime configuration via Git-tracked `.env` files **or** populate the `ENV_STAGE` / `ENV_PROD` GitHub variables with the exact `.env` content you want injected per environment.
6979
3. **Populate GitHub Secrets** with the values listed above.
7080
4. **Adopt the branch convention**:
7181
- Push or merge to `staging` for deploying to staging Adobe workspaces.

0 commit comments

Comments
 (0)