Skip to content

[DevOps] PR Builds: PR deployment and cleanup workflows#2033

Open
flanakin wants to merge 4 commits intodevfrom
flanakin/pr-deploy-workflows
Open

[DevOps] PR Builds: PR deployment and cleanup workflows#2033
flanakin wants to merge 4 commits intodevfrom
flanakin/pr-deploy-workflows

Conversation

@flanakin
Copy link
Collaborator

@flanakin flanakin commented Feb 28, 2026

🛠️ Description

Adds two GitHub Actions workflows for per-PR template deployment CI:

ftk-pr-deploy.yml

  • Triggers on PRs that change src/templates/** files (excluding docs/tests)
  • Parses PR body checkboxes (from [DevOps] PR Builds: Add deployment checkboxes to PR template #2031) to determine which deployments to run
  • 6 deployment variants run in parallel with isolated resource groups (pr-{number}-{variant}):
    • Hubs with ADX (managed exports)
    • Hubs with Fabric (manual exports)
    • Hubs storage-only (manual exports)
    • Hubs storage-only (no data)
    • Workbooks
    • Alerts
  • Posts PR comments with deployment status and Azure portal links
  • Supports fork PRs via Needs: Deployment label + pull_request_target (verifies no .github/ modifications)
  • Concurrency group cancels in-progress deployments on new pushes

ftk-pr-cleanup.yml

  • Triggers on PR close (merged or not)
  • Deletes all resource groups matching pr-{number}-*
  • Posts cleanup confirmation comment
  • Creates a GitHub issue assigned to the PR author if cleanup fails

Dependencies

This is PR D (final) of a multi-PR effort to add per-PR deployment CI.

📋 Checklist

🔬 How did you test this change?

  • 🤏 Lint tests
  • 🤞 PS -WhatIf / az validate
  • 👍 Manually deployed + verified
  • 💪 Unit tests
  • 🙌 Integration tests

📦 Deploy to test?

  • Hubs + ADX (managed)
  • Hubs + Fabric (manual) — URI:
  • Hubs (manual)
  • Hubs (no data)
  • Workbooks
  • Alerts

🙋‍♀️ Do any of the following that apply?

  • 🚨 This is a breaking change.
  • 🤏 The change is less than 20 lines of code.

📑 Did you update docs/changelog.md?

  • ✅ Updated changelog (required for dev PRs)
  • ➡️ Will add log in a future PR (feature branch PRs only)
  • ❎ Log not needed (small/internal change)

📖 Did you update documentation?

  • ✅ Public docs in docs (required for dev)
  • ✅ Public docs in docs-mslearn (required for dev)
  • ✅ Internal dev docs in docs-wiki (required for dev)
  • ✅ Internal dev docs in src (required for dev)
  • ➡️ Will add docs in a future PR (feature branch PRs only)
  • ❎ Docs not needed (small/internal change)

Creates two GitHub Actions workflows for per-PR template deployments:

ftk-pr-deploy.yml:
- Triggers on PRs that change src/templates/** files
- Parses PR body checkboxes to determine deployment variants
- Supports: ADX (managed), Fabric (manual), manual, no-data, workbooks, alerts
- Each variant deploys in parallel with isolated resource groups (pr-{number}-{variant})
- Posts PR comments with deployment status and portal links
- Supports fork PRs via "Needs: Deployment" label + pull_request_target
- Verifies fork PRs don't modify .github/ files

ftk-pr-cleanup.yml:
- Triggers on PR close (merged or not)
- Deletes all resource groups matching pr-{number}-*
- Posts cleanup confirmation comment
- Creates GitHub issue assigned to PR author if cleanup fails

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@flanakin flanakin requested a review from MSBrett as a code owner February 28, 2026 11:47
Copilot AI review requested due to automatic review settings February 28, 2026 11:47
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Review 👀 PR that is ready to be reviewed label Feb 28, 2026
@microsoft-github-policy-service microsoft-github-policy-service bot added the Skill: DevOps GitHub setup and automation label Feb 28, 2026
@flanakin flanakin changed the title Add per-PR deployment and cleanup workflows [DevOps] PR Builds: PR deployment and cleanup workflows Feb 28, 2026
@flanakin flanakin marked this pull request as draft February 28, 2026 11:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds GitHub Actions workflows to support per-PR Azure template deployments (FinOps hubs + variants, workbooks, alerts) and automatic cleanup of PR-specific resource groups, aligning with the toolkit’s CI automation goals for validating src/templates/** changes.

Changes:

  • Introduces ftk-pr-deploy.yml to parse PR-body deployment checkboxes and run selected deployments with PR-scoped resource groups.
  • Introduces ftk-pr-cleanup.yml to delete PR-scoped resource groups on PR close and notify via PR comment / issue on failure.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
.github/workflows/ftk-pr-deploy.yml New per-PR deployment workflow (checkbox parsing, fork label gating, parallel deployment jobs, PR comments).
.github/workflows/ftk-pr-cleanup.yml New cleanup workflow to remove pr-{number}-* resource groups and report failures.

flanakin and others added 2 commits February 28, 2026 22:19
- Fix PR body script injection: use env var instead of inline interpolation
- Escape literal + in regex patterns for checkbox matching
- Fix azure/login: use @v2 release tag instead of branch ref
- Fix job name typo: "Hubs + (manual)" → "Hubs (manual)"
- Remove unused any-selected output

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Tighten pull_request_target condition to only fire on Needs: Deployment label
- Expand fork safety check to block src/scripts/ changes
- Add Fabric URI validation before deploy (fails fast as first step)
- Change cleanup trigger to pull_request_target for fork PR secret access
- Add -ErrorAction Stop to Remove-AzResourceGroup for proper error handling
- Fix assignee fallback for external contributors on cleanup failure issues

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@flanakin
Copy link
Collaborator Author

flanakin commented Mar 1, 2026

🤖 [AI][Claude] PR Update Summary

Addressed: 9 thread(s)

  • ✅ Implemented: 6
  • 🤔 Needs discussion: 3

Changes:

  • Tightened pull_request_target condition to only fire on Needs: Deployment label
  • Expanded fork safety check to also block src/scripts/ changes (security)
  • Added Fabric URI validation as first step in deploy-fabric job (fail fast)
  • Changed cleanup trigger to pull_request_target for fork PR secret access
  • Added -ErrorAction Stop to Remove-AzResourceGroup for proper try/catch behavior
  • Split issue creation and assignee into separate steps with fallback for external contributors

Push-backs (code already correct):

  • grep + escaping — patterns already use \+ which is correct in ERE
  • PR body injection — already using env: var, not inlined in shell
  • Deploy-Hub params dependency — known, covered by draft status

@flanakin flanakin added this to the v14 milestone Mar 2, 2026
- Fix fabric-uri script injection: pass via env var instead of direct interpolation
- Add environment approval gate comment for fork PR security
- Add timeout-minutes: 60 to all deployment jobs
- Centralize Az module versions as workflow-level env vars
- Cache Az modules in check-options, restore in deployment jobs
- Update Deploy-Hub calls to use -PR {number} -Name "{variant}"

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: RolandKrummenacher <RolandKrummenacher@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@flanakin
Copy link
Collaborator Author

flanakin commented Mar 4, 2026

🤖 [AI][Claude] PR Update Summary

Addressed: 5 thread(s)

  • ✅ Implemented: 5
  1. Fixed fabric-uri script injection — passed via env var instead of direct interpolation
  2. Added environment approval gate comment for fork PR security (ftk-pr must have required reviewers)
  3. Extracted Az module install to check-options with caching; deployment jobs restore from cache
  4. Added timeout-minutes: 60 to all deployment jobs
  5. Centralized Az module versions as workflow-level env vars

Also updated all Deploy-Hub calls to use -PR {number} -Name "{variant}" per PR #2030 changes.

@flanakin flanakin marked this pull request as ready for review March 14, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Review 👀 PR that is ready to be reviewed Skill: DevOps GitHub setup and automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants