diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 15802cdef2..23b05de88a 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -15,6 +15,10 @@ on: - "ubuntu-latest" - "self-hosted" default: "self-hosted" + force_pr: + description: "Force a PR to be created" + type: boolean + default: false # Cancel if a newer run is started concurrency: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d4710976d..9a41f95e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ - Update CI to use nf-core/setup-nextflow v2 ([#2819](https://github.com/nf-core/tools/pull/2819)) - Changelog bot: handle also patch version before dev suffix ([#2820](https://github.com/nf-core/tools/pull/2820)) +- Add `force_pr` flag to sync, to force a PR even though there are no changes committed ([#2822](https://github.com/nf-core/tools/pull/2822)) - Update prettier to 3.2.5 ([#2830](https://github.com/nf-core/tools/pull/2830)) - Update GitHub Actions ([#2827](https://github.com/nf-core/tools/pull/2827)), ([#2902](https://github.com/nf-core/tools/pull/2902)), ([#2927](https://github.com/nf-core/tools/pull/2927)), ([#2939](https://github.com/nf-core/tools/pull/2939)) - Switch to setup-nf-test ([#2834](https://github.com/nf-core/tools/pull/2834)) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 39a1afbf63..147b0586b2 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -2147,10 +2147,16 @@ def logo(logo_text, dir, name, theme, width, format, force): default=False, help="Make a GitHub pull-request with the changes.", ) +@click.option( + "--force_pr", + is_flag=True, + default=False, + help="Force the creation of a pull-request, even if there are no changes.", +) @click.option("-g", "--github-repository", type=str, help="GitHub PR: target repository.") @click.option("-u", "--username", type=str, help="GitHub PR: auth username.") @click.option("-t", "--template-yaml", help="Pass a YAML file to customize the template") -def sync(dir, from_branch, pull_request, github_repository, username, template_yaml): +def sync(dir, from_branch, pull_request, github_repository, username, template_yaml, force_pr): """ Sync a pipeline [cyan i]TEMPLATE[/] branch with the nf-core template. @@ -2170,7 +2176,7 @@ def sync(dir, from_branch, pull_request, github_repository, username, template_y is_pipeline_directory(dir) # Sync the given pipeline dir - sync_obj = PipelineSync(dir, from_branch, pull_request, github_repository, username, template_yaml) + sync_obj = PipelineSync(dir, from_branch, pull_request, github_repository, username, template_yaml, force_pr) try: sync_obj.sync() except (SyncExceptionError, PullRequestExceptionError) as e: diff --git a/nf_core/sync.py b/nf_core/sync.py index 93a79c3d50..5e7b198d8d 100644 --- a/nf_core/sync.py +++ b/nf_core/sync.py @@ -44,6 +44,7 @@ class PipelineSync: gh_username (str): GitHub username gh_repo (str): GitHub repository name template_yaml_path (str): Path to template.yml file for pipeline creation settings. DEPRECATED + force_pr (bool): Force the creation of a pull request, even if there are no changes to the template Attributes: pipeline_dir (str): Path to target pipeline directory @@ -64,6 +65,7 @@ def __init__( gh_repo=None, gh_username=None, template_yaml_path=None, + force_pr=False, ): """Initialise syncing object""" @@ -76,6 +78,7 @@ def __init__( self.make_pr = make_pr self.gh_pr_returned_data = {} self.required_config_vars = ["manifest.name", "manifest.description", "manifest.version", "manifest.author"] + self.force_pr = force_pr self.gh_username = gh_username self.gh_repo = gh_repo @@ -132,8 +135,12 @@ def sync(self): self.make_template_pipeline() self.commit_template_changes() + if not self.made_changes and self.force_pr: + log.info("No changes made to TEMPLATE, but PR forced") + self.made_changes = True + # Push and make a pull request if we've been asked to - if self.made_changes and self.make_pr: + if self.made_changes and self.make_pr or self.force_pr: try: # Check that we have an API auth token if os.environ.get("GITHUB_AUTH_TOKEN", "") == "":