|
1 | | -# com-acc-api-mesh-ci-cd |
2 | | -Its an Public repository for Adobe Api Mesh CI/CD flows |
| 1 | +# Adobe API Mesh CI/CD Template |
| 2 | + |
| 3 | +This repository is a lightweight starting point for teams that want a repeatable GitHub Actions pipeline for provisioning and updating Adobe API Mesh configurations. Fork it, drop in your mesh definition files, wire up the required Adobe Developer Console credentials, and you will have a push-button deployment path for staging and production meshes. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## What You Get |
| 8 | + |
| 9 | +- **Workflow automation** – `.github/workflows/deployMesh.yaml` handles checkout, authentication via the Adobe I/O CLI, mesh creation (or update), and post-deploy validation. |
| 10 | +- **Environment awareness** – pushes to `staging` or `production` automatically pull the corresponding credential set and workspace identifiers. |
| 11 | +- **Manual control** – trigger the workflow with `workflow_dispatch` whenever you need an ad-hoc deployment. |
| 12 | +- **Extensibility** – add new environments, steps, linters, or notifications by extending the single workflow file. |
| 13 | + |
| 14 | +Repository layout (expected): |
| 15 | + |
| 16 | +``` |
| 17 | +. |
| 18 | +├── .github/workflows/deployMesh.yaml # Main CI/CD pipeline |
| 19 | +├── mesh.json # API Mesh definition (commit your own) |
| 20 | +├── .env # Optional runtime variables used by mesh.json |
| 21 | +└── README.md # This documentation |
| 22 | +``` |
| 23 | + |
| 24 | +> Tip: keep secrets out of `mesh.json` and `.env`. Use GitHub Encrypted Secrets wherever possible. |
| 25 | +
|
| 26 | +--- |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +1. **Adobe Developer Console access** with permissions to the target organization, project, and workspaces that host your meshes. |
| 31 | +2. **Mesh definition files** (`mesh.json` plus any schema/resolver files) committed to the repository. |
| 32 | +3. **GitHub repository admin rights** to configure Actions secrets and branch protection rules. |
| 33 | +4. **Node.js 20.x** compatibility for any local development or custom steps (the workflow pins Node 20 via the matrix but can be adjusted). |
| 34 | +5. **Adobe I/O CLI knowledge** (`aio`) in case you want to run the same commands locally for troubleshooting. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Required GitHub Secrets |
| 39 | + |
| 40 | +Configure the following secrets under **Settings → Secrets and variables → Actions** in your fork. Stage/prod secrets allow the workflow to decide which credentials to use based on the branch being deployed. |
| 41 | + |
| 42 | +| Secret Name | When Used | Description | |
| 43 | +| --- | --- | --- | |
| 44 | +| `CLIENTID_STAGE`, `CLIENTSECRET_STAGE`, `TECHNICALACCID_STAGE`, `TECHNICALACCEMAIL_STAGE`, `WORKSPACEID_STAGE` | Pushes to `staging` | OAuth client + technical account bound to your staging workspace. | |
| 45 | +| `CLIENTID_PROD`, `CLIENTSECRET_PROD`, `TECHNICALACCID_PROD`, `TECHNICALACCEMAIL_PROD`, `WORKSPACEID_PROD` | Pushes to `production` | Production equivalents of the above credentials. | |
| 46 | +| `IMSORGID` | Both | Adobe organization ID hosting the project. | |
| 47 | +| `ORGID` | Both | Console organization identifier consumed by `aio console:org:select`. | |
| 48 | +| `PROJECTID` | Both | Console project identifier used by `aio console:project:select`. | |
| 49 | + |
| 50 | +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. |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## Quick Start |
| 55 | + |
| 56 | +1. **Fork this repo** or use it as a template inside your organization. |
| 57 | +2. **Add your mesh files**: |
| 58 | + - Place the primary mesh definition in `mesh.json`. |
| 59 | + - Commit any supporting schemas/resolvers alongside it. |
| 60 | + - (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. |
| 61 | +3. **Populate GitHub Secrets** with the values listed above. |
| 62 | +4. **Adopt the branch convention**: |
| 63 | + - Push or merge to `staging` for deploying to staging Adobe workspaces. |
| 64 | + - Push or merge to `production` for production deployments. |
| 65 | +5. **Run the pipeline**: |
| 66 | + - Commit changes and push to the target branch. |
| 67 | + - Or open the **Actions** tab, select **Deploy Mesh**, and click **Run workflow** (specify the target branch). |
| 68 | + |
| 69 | +Once the workflow succeeds, your Adobe API Mesh instance will be created (if missing) or updated using the latest `mesh.json` contents, then described and queried for status to confirm a healthy deployment. |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Workflow Walkthrough (`deployMesh.yaml`) |
| 74 | + |
| 75 | +1. **Checkout & Node setup** – pulls repository code and provisions Node 20 on `ubuntu-latest`. |
| 76 | +2. **Branch-aware env mapping** – resolves GitHub secrets to runtime variables (`TARGET_ENV`, `CLIENTID`, etc.). Only `staging` and `production` are allowed to prevent accidental deployments from other branches. |
| 77 | +3. **Secret validation** – fails fast if any required value is missing. |
| 78 | +4. **Adobe I/O CLI bootstrap** – installs `aio` plus the API Mesh plugin (`@adobe/aio-cli-plugin-api-mesh`). |
| 79 | +5. **Authentication & targeting** – performs `oauth_sts`, selects the right org/project/workspace, and prints the CLI config for traceability. |
| 80 | +6. **Mesh lifecycle** – runs `aio api-mesh:get`; if no mesh exists it calls `api-mesh:create`, otherwise `api-mesh:update`, then waits briefly, describes the mesh, and fetches status. |
| 81 | + |
| 82 | +Extend or reorder steps as needed (e.g., run linting/tests before deployment, send Slack notifications after success, etc.). |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## Customizing the Template |
| 87 | + |
| 88 | +- **Additional environments** – duplicate the branch/secrets mapping block and add new branches like `qa` or `dev` with their own credential sets. |
| 89 | +- **Matrix changes** – adjust `matrix.node-version` or `os` if you need different runtimes. |
| 90 | +- **Multiple meshes** – add extra steps to iterate over multiple `mesh.json` files or parameterize the mesh name via `.env` values. |
| 91 | +- **Observability** – append steps that push deployment metadata to your logging/monitoring stack. |
| 92 | + |
| 93 | +When editing `deployMesh.yaml`, keep the secret-validation step up to date so failures happen quickly. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## Local Validation (Optional) |
| 98 | + |
| 99 | +If you mirror the GitHub secrets as local environment variables you can run the same commands for smoke tests: |
| 100 | + |
| 101 | +```bash |
| 102 | +npm install -g @adobe/aio-cli |
| 103 | +aio plugins:install @adobe/aio-cli-plugin-api-mesh |
| 104 | +aio console:org:select <ORGID> |
| 105 | +aio console:project:select <PROJECTID> |
| 106 | +aio console:workspace:select <WORKSPACEID> |
| 107 | +aio api-mesh:update -c mesh.json --env .env |
| 108 | +``` |
| 109 | + |
| 110 | +This makes it easier to debug mesh misconfigurations before committing. |
| 111 | + |
| 112 | +--- |
| 113 | + |
| 114 | +## Troubleshooting |
| 115 | + |
| 116 | +- **Unsupported branch error** – ensure you are pushing to `staging` or `production`, or extend the branch mapping block for additional environments. |
| 117 | +- **Secret validation failure** – confirm every secret listed earlier is present; GitHub scope is repository-level by default. |
| 118 | +- **CLI auth issues** – verify the OAuth client has `oauth_sts` permissions and the scopes defined in the workflow. |
| 119 | +- **Mesh update fails** – inspect the workflow logs around `aio api-mesh:update` for schema/validation errors; run the same command locally with `--verbose` for more detail. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Next Steps |
| 124 | + |
| 125 | +- Protect the `production` branch to require PR reviews before deployment. |
| 126 | +- Wire Slack/Teams notifications by adding an extra step after `Get Mesh Status`. |
| 127 | +- Version your mesh definitions (e.g., tag releases) so you can roll back quickly if needed. |
| 128 | + |
| 129 | +Happy shipping! |
0 commit comments