Skip to content

feat: add {#[TOKEN_NAME]#} substitution step to publish pipelines (APIOps Toolkit parity)#127

Merged
petehauge merged 9 commits into
mainfrom
copilot/enable-pipeline-token-substitution
Jun 10, 2026
Merged

feat: add {#[TOKEN_NAME]#} substitution step to publish pipelines (APIOps Toolkit parity)#127
petehauge merged 9 commits into
mainfrom
copilot/enable-pipeline-token-substitution

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Users migrating from APIOps Toolkit expect {#[TOKEN_NAME]#} placeholders in configuration.<env>.yaml to be substituted from pipeline secrets before publish runs. Previously the generated pipelines had no substitution step, so tokens were passed as literal strings to APIM.

Pipeline changes

Both GitHub Actions and Azure DevOps publish templates now include a dedicated substitution step before apiops publish, using the same tools APIOps Toolkit uses:

GitHub Actionscschleiden/replace-tokens@v1.3:

- name: Substitute tokens in configuration.prod.yaml
  uses: cschleiden/replace-tokens@v1.3
  with:
    tokenPrefix: '{#['
    tokenSuffix: ']#}'
    files: '["configuration.prod.yaml"]'
  env:
    # MY_SECRET: ${{ secrets.MY_SECRET }}

Azure DevOpsreplacetokens@6 (reads from variable groups automatically):

- task: replacetokens@6
  displayName: 'Substitute tokens in configuration.prod.yaml'
  inputs:
    sources: 'configuration.prod.yaml'
    tokenPrefix: '{#['
    tokenSuffix: ']#}'

The step is generated once per environment, scoped to configuration.<env>.yaml.

Documentation

  • docs/guides/token-substitution.md — new guide covering syntax, GitHub Actions setup (secret → env var mapping), Azure DevOps setup (variable group), Toolkit migration guide, and common examples
  • docs/ci-cd/github-actions.md / docs/ci-cd/azure-devops.md — updated pipeline step descriptions and added customization tips linking to the new guide

Copilot AI changed the title [WIP] Add pipeline token substitution in publish pipeline feat: add {#[TOKEN_NAME]#} substitution step to publish pipelines (APIOps Toolkit parity) Jun 9, 2026
Copilot finished work on behalf of EMaher June 9, 2026 19:08
Copilot AI requested a review from EMaher June 9, 2026 19:08
Comment thread docs/ci-cd/azure-devops.md
Comment thread docs/ci-cd/azure-devops.md Outdated

1. **Install the [Replace Tokens extension](https://marketplace.visualstudio.com/items?itemName=qetza.replacetokens)** in your Azure DevOps organization (if not already installed).

2. **Add secret variables** to the `apim-<env>` variable group (e.g., `PROD_SECRET_VALUE`). Mark them as secret.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Add links to official documentation on how to add secrets to Azure DevOps.
  2. Add example usage of a token value in a config overrides file.

Comment thread docs/ci-cd/azure-devops.md
Comment thread docs/ci-cd/azure-devops.md
Comment thread docs/guides/token-substitution.md Outdated
value: "{#[BACKEND_API_URL]#}"
```

2. **Store actual values** in your pipeline's secret store (GitHub Actions Secrets or Azure DevOps variable groups / Key Vault).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Key Vault mentioned here?

Comment thread docs/guides/token-substitution.md Outdated

## Azure DevOps Setup

### Generated Step

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation details not needed.

Comment thread docs/guides/token-substitution.md Outdated

The `replacetokens` task automatically reads from pipeline variables (including those from variable groups). Add your secret values as variables in the `apim-<env>` variable group:

1. Go to **Pipelines → Library → apim-prod**

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be apim-<env>?

Comment thread docs/guides/token-substitution.md Outdated

If you are migrating from APIOps Toolkit, your existing `configuration.<env>.yaml` files that use `{#[TOKEN_NAME]#}` placeholders work without modification. The same syntax is supported.

The only difference is where secrets are stored and mapped:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the table necessary? table just shows everything is identity, which you've already stated.

Comment thread docs/guides/token-substitution.md Outdated
| **Azure DevOps** | `qetza.replacetokens@6` | `replacetokens@6` (same extension) |
| **Token prefix/suffix** | `{#[` / `]#}` | `{#[` / `]#}` (identical) |

### Migration Steps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this. We'll have an all-up migration doc elsewhere

Comment thread docs/guides/token-substitution.md Outdated

## Security Notes

- Tokens are replaced **in the pipeline runner's memory** — they are never committed to the repository.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really true? We are using extensions, so how can we state their behavior? Are there links to extension documentation that state this?

@EMaher EMaher left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Please handle feedback.

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please handle feedback.

All review feedback addressed in commit docs: address PR review feedback on token substitution docs:

docs/guides/token-substitution.md:

  • Removed Key Vault mention from "How It Works" intro
  • Removed the "Mapping Secrets to Tokens" implementation-detail section; kept the case-sensitivity note as a [!IMPORTANT] GitHub callout
  • Removed the "Generated Step" Azure DevOps section (implementation detail)
  • Converted the prerequisite note to [!IMPORTANT] GitHub callout
  • Fixed apim-prodapim<env> (and in the step-by-step and example sections)
  • Removed the identity-mapping table from the Migration section
  • Removed the "Migration Steps" subsection
  • Revised Security Notes to remove unverifiable claims about extension internals

docs/ci-cd/azure-devops.md:

  • Removed the YAML task code block from "Using Token Substitution"
  • Added links to official Azure DevOps documentation for variable groups and secret variables, plus a concrete config file example
  • Renamed ## Related## Further Reading

Copilot finished work on behalf of EMaher June 9, 2026 19:57
Copilot AI requested a review from EMaher June 9, 2026 19:57
Copilot AI and others added 6 commits June 10, 2026 02:43
Adds {#[TOKEN_NAME]#} substitution as a dedicated step in both
GitHub Actions and Azure DevOps publish pipelines generated by
`apiops init`, compatible with APIOps Toolkit configuration files.

- GitHub Actions: cschleiden/replace-tokens@v1.3 with {#[ / ]#}
- Azure DevOps: replacetokens@6 with {#[ / ]#}
- Step runs before apiops publish so secrets are never committed
- New docs/guides/token-substitution.md covering syntax, setup,
  migration from APIOps Toolkit, and common examples
- Updated ci-cd/github-actions.md and ci-cd/azure-devops.md

Closes #36
@EMaher EMaher force-pushed the copilot/enable-pipeline-token-substitution branch from 966636d to 89d547f Compare June 10, 2026 02:44
@EMaher EMaher marked this pull request as ready for review June 10, 2026 05:51
@petehauge petehauge merged commit bab1c32 into main Jun 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable pipeline token/placeholder substitution in publish pipeline (APIOps Toolkit parity)

3 participants