Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/main/resources/META-INF/rewrite/github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ recipeList:
fileMatcher: '.github/workflows/*.{yml,yaml}'
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.github.AddMergeGroupTrigger
displayName: Add `merge_group` workflow trigger
description: Trigger workflows for pull requests queued in a [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue).
tags:
- github
preconditions:
- org.openrewrite.yaml.search.FindKey:
key: $.on.pull_request
recipeList:
- org.openrewrite.yaml.MergeYaml:
key: $.on
yaml: |-
merge_group:
acceptTheirs: true
filePattern: '.github/workflows/*.{yml,yaml}'
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.github.DependabotCheckForGithubActionsUpdatesDaily
displayName: Check for github-actions updates daily
description: Set dependabot to check for github-actions updates daily.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/recipes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ ecosystem,packageName,name,displayName,description,recipeCount,category1,categor
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.AddCronTrigger,Add cron workflow trigger,The `schedule` [event](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events) allows you to trigger a workflow at a scheduled time.,1,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,"[{""name"":""cron"",""type"":""String"",""displayName"":""Cron expression"",""description"":""Using the [POSIX cron syntax](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html#tag_20_25_07) or the non standard options @hourly @daily @weekly @weekdays @weekends @monthly @yearly."",""example"":""@daily"",""required"":true},{""name"":""workflowFileMatcher"",""type"":""String"",""displayName"":""Workflow files to match"",""description"":""Matches one or more workflows to update. Defaults to `*.{yml,yaml}`"",""example"":""build.yml""}]",
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.AddDependabotCooldown,Add cooldown periods to Dependabot configuration,"Adds a `cooldown` section to each update configuration in Dependabot files. Supports `default-days`, `semver-major-days`, `semver-minor-days`, `semver-patch-days`, `include`, and `exclude` options. This implements a security best practice where dependencies are not immediately adopted upon release, allowing time for security vendors to identify potential supply chain compromises. Cooldown applies only to version updates, not security updates. [Read more about dependency cooldowns](https://blog.yossarian.net/2025/11/21/We-should-all-be-using-dependency-cooldowns). [The available configuration options for dependabot are listed on GitHub](https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates).",1,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,"[{""name"":""cooldownDays"",""type"":""Integer"",""displayName"":""Default cooldown days"",""description"":""The number of days to wait before considering a published dependency suitable for use (1-90). This delay allows security vendors time to identify potential compromises. Applied to all version types unless specific semver options are set."",""example"":""7""},{""name"":""semverMajorDays"",""type"":""Integer"",""displayName"":""Semver major cooldown days"",""description"":""The number of days to wait for major version updates (1-90). Only applies to package managers that support semantic versioning."",""example"":""14""},{""name"":""semverMinorDays"",""type"":""Integer"",""displayName"":""Semver minor cooldown days"",""description"":""The number of days to wait for minor version updates (1-90). Only applies to package managers that support semantic versioning."",""example"":""7""},{""name"":""semverPatchDays"",""type"":""Integer"",""displayName"":""Semver patch cooldown days"",""description"":""The number of days to wait for patch version updates (1-90). Only applies to package managers that support semantic versioning."",""example"":""3""},{""name"":""include"",""type"":""List"",""displayName"":""Include dependencies"",""description"":""List of up to 150 dependencies to apply cooldown to. Supports wildcard patterns with `*`. If not specified, cooldown applies to all dependencies."",""example"":""lodash, react*""},{""name"":""exclude"",""type"":""List"",""displayName"":""Exclude dependencies"",""description"":""List of up to 150 dependencies to exempt from cooldown. Supports wildcard patterns with `*`. Exclude list takes precedence over include list."",""example"":""critical-security-package""},{""name"":""excludeEcosystems"",""type"":""List"",""displayName"":""Exclude ecosystems"",""description"":""List of ecosystems to be excluded"",""example"":""github-actions""}]",
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.AddManualTrigger,Add manual workflow trigger,"You can manually trigger workflow runs. To trigger specific workflows in a repository, use the `workflow_dispatch` event.",2,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,,
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.AddMergeGroupTrigger,Add `merge_group` workflow trigger,Trigger workflows for pull requests queued in a [merge queue](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue).,2,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,,
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.AutoCancelInProgressWorkflow,Cancel in-progress workflow when it is triggered again,"When a workflow is already running and would be triggered again, cancel the existing workflow, through the native [`concurrency`](https://docs.github.com/en/actions/using-jobs/using-concurrency) property. Runs on the default branch are not cancelled.",2,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,,
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.ChangeAction,Change GitHub Action,Change a GitHub Action in any workflow.,1,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,"[{""name"":""oldAction"",""type"":""String"",""displayName"":""Action"",""description"":""Name of the action to match."",""example"":""gradle/wrapper-validation-action"",""required"":true},{""name"":""oldSha"",""type"":""String"",""displayName"":""Old commit SHA"",""description"":""Restricts the change by the existing `uses:` ref. When omitted, the action is changed regardless of how it is pinned (the default; commit SHA pins are rewritten). When set to an empty string, only references that are **not** pinned to a 40-character commit SHA are changed, leaving deliberate SHA pins on the original action untouched. When set to a specific commit SHA, only references pinned to exactly that SHA are changed."",""example"":""8f4b7f84864484a7bf31766abe9204da3cbe65b3""},{""name"":""newAction"",""type"":""String"",""displayName"":""Action"",""description"":""Name of the action to use instead."",""example"":""gradle/actions/wrapper-validation"",""required"":true},{""name"":""newVersion"",""type"":""String"",""displayName"":""Version"",""description"":""New version to use."",""example"":""v3"",""required"":true}]",
maven,org.openrewrite.recipe:rewrite-github-actions,org.openrewrite.github.ChangeActionVersion,Change GitHub Action version,Change the version of a GitHub Action in any workflow.,1,,GitHub Actions,,Recipes to perform [GitHub Actions](https://docs.github.com/en/actions) hygiene and migration tasks.,"[{""name"":""action"",""type"":""String"",""displayName"":""Action"",""description"":""Name of the action to update."",""example"":""actions/setup-java"",""required"":true},{""name"":""version"",""type"":""String"",""displayName"":""Version"",""description"":""Version to use."",""example"":""v4"",""required"":true},{""name"":""oldSha"",""type"":""String"",""displayName"":""Old commit SHA"",""description"":""Restricts the change by the existing `uses:` ref. When omitted, the version is changed regardless of how the action is pinned (the default; commit SHA pins are rewritten). When set to an empty string, only references that are **not** pinned to a 40-character commit SHA are changed, preserving deliberate SHA pins. When set to a specific commit SHA, only references pinned to exactly that SHA are changed."",""example"":""8f4b7f84864484a7bf31766abe9204da3cbe65b3""}]",
Expand Down
112 changes: 112 additions & 0 deletions src/test/java/org/openrewrite/github/AddMergeGroupTriggerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright 2026 the original author or authors.
* <p>
* Licensed under the Moderne Source Available License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* https://docs.moderne.io/licensing/moderne-source-available-license
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.github;

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.yaml.Assertions.yaml;

class AddMergeGroupTriggerTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipeFromResources("org.openrewrite.github.AddMergeGroupTrigger");
}

@DocumentExample
@Test
void addsMergeGroupTriggerToPullRequestWorkflow() {
rewriteRun(
//language=yaml
yaml(
"""
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
""",
"""
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
jobs:
build:
runs-on: ubuntu-latest
""",
source -> source.path(".github/workflows/ci.yml")
)
);
}

@Test
void leavesWorkflowWithoutPullRequestTriggerUnchanged() {
rewriteRun(
//language=yaml
yaml(
"""
on:
push:
branches:
- main
""",
source -> source.path(".github/workflows/ci.yml")
)
);
}

@Test
void leavesExistingMergeGroupTriggerUnchanged() {
rewriteRun(
//language=yaml
yaml(
"""
on:
pull_request:
merge_group:
""",
source -> source.path(".github/workflows/ci.yaml")
)
);
}

@Test
void leavesNonWorkflowFileUnchanged() {
rewriteRun(
//language=yaml
yaml(
"""
on:
pull_request:
""",
source -> source.path("workflow.yml")
)
);
}
}
Loading