Skip to content

Run initialize-cloud only with 'test deployment' label#5933

Merged
kzuraw merged 5 commits intomainfrom
gha-initialize-cloud-label-trigger
Oct 2, 2025
Merged

Run initialize-cloud only with 'test deployment' label#5933
kzuraw merged 5 commits intomainfrom
gha-initialize-cloud-label-trigger

Conversation

@kzuraw
Copy link
Contributor

@kzuraw kzuraw commented Oct 2, 2025

Summary

  • Modified PR automation workflow to run only on labeled events (when a label is added to PR)
  • Added condition to initialize-cloud job to run only when PR has "test deployment" label
  • Kept workflow_dispatch trigger for manual execution
  • This creates a dual-layer optimization for resource usage

Changes

.github/workflows/pr-automation.yml:

  1. Trigger optimization: Changed from multiple PR events to only labeled event

    on:
      pull_request:
        types: [labeled]  # Previously: [opened, reopened, synchronize, labeled]
      workflow_dispatch:
  2. Job condition: Added check to initialize-cloud job

    if: ${{ contains(github.event.pull_request.labels.*.name, 'test deployment') }}

Benefits

  • Maximum resource optimization: Workflow only triggers when labels are added (not on every push)
  • Explicit opt-in: Cloud resources are only provisioned when "test deployment" label is explicitly added
  • Cost savings: Dramatically reduces unnecessary workflow runs and cloud resource usage
  • Manual override: Teams can still manually trigger via workflow_dispatch when needed
  • Dependent jobs (deploy-dashboard, run-tests) are automatically skipped when conditions aren't met

Behavior

When workflow runs:

  1. Label added to PR → Workflow triggers
    • If label is "test deployment" → initialize-cloud runs → deployment happens
    • If label is NOT "test deployment" → initialize-cloud is skipped → no deployment
  2. Manual trigger via workflow_dispatchinitialize-cloud runs → deployment happens

When workflow does NOT run:

  • PR opened/reopened
  • New commits pushed to PR (synchronize)
  • PR unlabeled
  • Any other PR events

Test plan

  • Create a test PR and add a non-deployment label - verify workflow runs but initialize-cloud is skipped
  • Add "test deployment" label to PR - verify workflow runs and initialize-cloud provisions environment
  • Push new commits to PR with label - verify workflow does NOT trigger
  • Manually trigger workflow via Actions UI - verify it runs successfully

🤖 Generated with Claude Code

- Added conditional check to initialize-cloud job to run only when PR has "test deployment" label
- This prevents unnecessary cloud instance initialization for PRs that don't need deployment testing
- Dependent jobs (deploy-dashboard, run-tests) already have their own conditions and will be skipped accordingly

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

Co-Authored-By: Claude <noreply@anthropic.com>
@kzuraw kzuraw requested a review from a team as a code owner October 2, 2025 12:52
@kzuraw kzuraw requested review from Copilot, lkostrowski and witoszekdev and removed request for Copilot October 2, 2025 12:52
@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2025

⚠️ No Changeset found

Latest commit: 9820c24

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
saleor-dashboard-storybook Ignored Ignored Preview Oct 2, 2025 1:08pm

witoszekdev
witoszekdev previously approved these changes Oct 2, 2025
Copilot AI review requested due to automatic review settings October 2, 2025 12:56
@kzuraw kzuraw force-pushed the gha-initialize-cloud-label-trigger branch from b03bde7 to 443d46b Compare October 2, 2025 12:56
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

This PR optimizes the PR automation workflow by conditionally running cloud initialization only when needed, and removes obsolete TypeScript directives.

  • Added conditional execution to initialize-cloud job based on "test deployment" label
  • Removed unused @ts-expect-error directive from RichTextEditor constants
  • Reduces unnecessary cloud resource usage for PRs that don't require deployment testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

kzuraw and others added 2 commits October 2, 2025 14:59
- Changed pull_request trigger to only run on 'labeled' events
- Removed 'opened', 'reopened', and 'synchronize' from trigger types
- Kept workflow_dispatch for manual triggering
- Combined with the initialize-cloud condition, workflow now only runs when:
  1. A label is added to PR AND it's the "test deployment" label, OR
  2. Workflow is manually triggered via workflow_dispatch

This further reduces unnecessary workflow runs and cloud resource usage.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Added optional API_URL input parameter to workflow_dispatch
- When provided, API_URL input overrides the cloud-generated API_URL
- Updated initialize-cloud outputs to use: inputs.API_URL || steps.cloud_variables.outputs.API_URL
- Updated prepare-instance action call to use the same conditional logic
- All downstream jobs (deploy-dashboard, run-tests) automatically use the overridden API_URL via needs.initialize-cloud.outputs.API_URL

This allows developers to manually trigger the workflow against a custom Saleor backend instance for testing purposes.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings October 2, 2025 13:02
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kzuraw kzuraw added the skip changeset Use if your changes doesn't need entry in changelog label Oct 2, 2025
kzuraw and others added 2 commits October 2, 2025 15:06
- Updated initialize-cloud job condition to handle workflow_dispatch events
- Added check: github.event_name == 'workflow_dispatch' || contains(labels, 'test deployment')
- Prevents null reference error when workflow is manually triggered (PR context is null)

Co-authored-by: Copilot <noreply@github.com>

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

Co-Authored-By: Claude <noreply@anthropic.com>
@kzuraw kzuraw added the test deployment Deploy Pull Request to *.saleor.rocks environment label Oct 2, 2025
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.06%. Comparing base (f666a69) to head (9820c24).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5933   +/-   ##
=======================================
  Coverage   40.06%   40.06%           
=======================================
  Files        2473     2473           
  Lines       40170    40170           
  Branches     9151     9151           
=======================================
  Hits        16093    16093           
  Misses      22867    22867           
  Partials     1210     1210           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kzuraw kzuraw merged commit 85a35c0 into main Oct 2, 2025
24 checks passed
@kzuraw kzuraw deleted the gha-initialize-cloud-label-trigger branch October 2, 2025 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Use if your changes doesn't need entry in changelog test deployment Deploy Pull Request to *.saleor.rocks environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants