Skip to content

PublishToEnvironment: Deployment not tracked against PR branch when using appVersion: PR_<ID> #2118

@StefanMaron

Description

@StefanMaron

Description

When using the PublishToEnvironment workflow to deploy a PR from the main branch (using appVersion: PR_<PR_ID>), the deployment is registered against the workflow's trigger ref (main) instead of the actual PR branch being deployed.

This causes GitHub's PR interface to show "This branch has not been deployed" even though the PR has been successfully deployed.

Current Behavior

  1. Run PublishToEnvironment workflow from main branch
  2. Set appVersion: PR_123 to deploy a specific PR
  3. Workflow successfully deploys the PR code
  4. GitHub creates deployment record against main branch (workflow trigger)
  5. PR AL-Go for on-prem BC? #123 shows "This branch has not been deployed" ❌

Expected Behavior

When appVersion matches pattern PR_<ID>:

  1. Workflow should detect this is a PR deployment
  2. Fetch the PR branch name via GitHub API
  3. Create deployment record against the PR branch (not workflow trigger ref)
  4. PR shows correct deployment status ✅

Why This Matters

Common use case: Running deployments from main with environment protection rules, while deploying feature branch code. This pattern allows:

  • Centralized deployment control from main branch
  • Environment protection rules enforcement
  • PR-based artifact deployment
  • Clear deployment visibility in PR interface

Without proper deployment tracking, teams lose visibility into which PRs have been deployed to which environments.

Proposed Solution

Modify PublishToEnvironment.yaml Deploy job to:

  1. Add deployments: write permission
  2. Before deployment, detect if appVersion matches PR_<ID> pattern
  3. If yes, fetch PR branch ref via GitHub API
  4. Create explicit deployment record against PR branch using GitHub Deployments API
  5. Update deployment status after deployment completes

This preserves all existing functionality while correctly tracking PR deployments.

Workaround

Users can manually add deployment tracking logic to their workflows (see solution above), but this should be built into AL-Go's template.

Environment

  • AL-Go Version: v8.1 (issue also present in v8.2)
  • Template: Per Tenant Extension (PTE)
  • Workflow: PublishToEnvironment.yaml

Related

GitHub's environment: key automatically creates deployments against the workflow trigger ref, which is the root cause of this issue. Explicit API calls are needed to override this behavior for PR deployments.

Metadata

Metadata

Assignees

Labels

Fix ReadyFix ReadyIn ProgressIssue is actively being worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions