Skip to content

fix: push trigger in generated publish workflow never ran any jobs#76

Draft
EMaher wants to merge 5 commits into
mainfrom
copilot/add-support-publish-last-commit
Draft

fix: push trigger in generated publish workflow never ran any jobs#76
EMaher wants to merge 5 commits into
mainfrom
copilot/add-support-publish-last-commit

Conversation

@EMaher
Copy link
Copy Markdown
Contributor

@EMaher EMaher commented May 19, 2026

The apiops init GitHub Actions publish workflow had a push trigger, but every publish-* job was gated on github.event.inputs.ENVIRONMENT, which is undefined on push events. The trigger fired but all jobs were skipped — a silent no-op.

Changes

  • src/templates/github-actions/publish-workflow.ts

    • First environment's job condition now includes || github.event_name == 'push', so merges to main automatically trigger an incremental publish
    • On push, COMMIT_ID_CHOICE is undefined → != 'publish-all-artifacts-in-repo' is true → --commit-id ${{ needs.get-commit.outputs.commit_id }} is passed automatically
    • Subsequent environments remain gated on explicit workflow_dispatch (safe default for production)
    • Comments updated to show how to opt subsequent environments into sequential push-triggered deployment
  • tests/unit/templates/github-actions/publish-workflow.test.ts

    • 3 new tests: first env condition includes push trigger, subsequent envs do not, incremental step correctly wires --commit-id for push case

Before (first env job, all envs identical):

if: github.event.inputs.ENVIRONMENT == 'dev'   # always false on push

After:

# Automatically deploys to dev on push to main (incremental mode) or when selected via workflow_dispatch
if: github.event.inputs.ENVIRONMENT == 'dev' || github.event_name == 'push'

Copilot AI and others added 2 commits May 19, 2026 11:52
…flow

The publish-workflow.ts template's push trigger was configured but all
publish jobs were gated on `github.event.inputs.ENVIRONMENT`, which is
undefined on push events, so no publish job ever ran on push.

Fix: enable the first environment's job to also run on push to main, so
that merges to main automatically trigger an incremental publish using
GITHUB_SHA as the commit-id. Subsequent environments remain opt-in via
workflow_dispatch (safe default for production gating).

- First environment job condition: `ENVIRONMENT == 'dev' || event_name == 'push'`
- Subsequent environments: gated on ENVIRONMENT input only, with
  comment showing how to chain sequential push-triggered deployment
- The incremental step's `--commit-id` is already wired correctly via
  `needs.get-commit.outputs.commit_id` (from GITHUB_SHA); on push,
  COMMIT_ID_CHOICE is empty so `!= 'publish-all-artifacts-in-repo'`
  is true, automatically selecting incremental mode

Added 3 new tests covering:
- First env runs on push (event_name condition present)
- Subsequent envs do NOT auto-run on push
- commit-id is passed via incremental step condition

Closes #46

Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/fc5694e2-a9e3-4a49-948a-9c1bfad737f1

Co-authored-by: EMaher <9244742+EMaher@users.noreply.github.com>
@EMaher EMaher assigned EMaher and unassigned EMaher May 19, 2026
@EMaher
Copy link
Copy Markdown
Contributor Author

EMaher commented May 19, 2026

@copilot Have the Squad fan out and verify the code changes make the default behavoir for apiops init --ci azuredevops match the behavior description in https://azure.github.io/apiops/apiops/5-publishApimArtifacts/apiops-github-4-2-pipeline.html.

Create pipeline to automatically push changes using publisher tool
Go back to the PR that was created in the previous step as a result of running the extractor. Once the PR is merged the run-publisher pipeline should automatically trigger. Remember that the publisher pipeline requires manual approval before promoting between stages. To promote to the prod environment, wait on the dev stage to succeed and then click on the “Review deployments” button and approve to deploy the changes to the prod environment. approve promotion to prod environment

Specifically, I think the 'require human approval' part is missing.

Copilot AI and others added 2 commits May 19, 2026 21:32
…ates

GitHub Actions:
- All environments now run in sequence on push to main (chained with needs)
- Subsequent env jobs have needs: [get-commit, publish-{prevEnv}] for sequential promotion
- Non-first environments include a comment directing users to configure
  Required Reviewers in GitHub Settings > Environments > {env}
- This enables the "Review deployments" approval button flow on push

Azure DevOps:
- Fix dependsOn placement: moved inside stage definition (was incorrectly
  placed before the `- stage:` entry in the YAML list)
- Non-first stages now include a comment directing users to configure
  approval checks in Pipelines > Environments > {env}

Tests updated to reflect all environments running on push and
the new approval guidance comments.

Closes #46

Agent-Logs-Url: https://github.com/Azure/apiops-cli/sessions/af96f6ab-4bfa-485c-8b3e-a19edca3cb60

Co-authored-by: EMaher <9244742+EMaher@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented May 19, 2026

@copilot Have the Squad fan out and verify the code changes make the default behavoir for apiops init --ci azuredevops match the behavior description in https://azure.github.io/apiops/apiops/5-publi...

Done in commit d9170d6. Here's what changed:

GitHub Actions (publish-workflow.ts):

  • All environments now chain sequentially on push to main (not just dev): each non-first job gets needs: [get-commit, publish-{previousEnvironment}]
  • This makes all environments run in the same workflow run, which is required for the GitHub "Review deployments" approval button to appear
  • Non-first environments now include a comment directing users to configure Required Reviewers under Settings > Environments > {env} — that's the mechanism that gates promotion with human approval

Azure DevOps (publish-pipeline.ts):

  • Fixed a pre-existing YAML structure bug: dependsOn is now correctly placed inside the stage definition (previously it was placed before - stage:, outside the entry)
  • Non-first stages include a comment directing users to configure approval checks in Pipelines > Environments > {env}
  • The sequential dependsOn chaining was already in place; the approval gate is now explicitly documented

Both templates now match the documented behavior: push to main → auto-deploys to first env (incremental, using --commit-id) → subsequent envs require human approval before proceeding.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azure.github.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of EMaher May 19, 2026 21:34
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.

2 participants