Skip to content

Add an option to create a new branch from the default branch if the specified ref does not exist #1920

Open
@Shion1305

Description

@Shion1305

Problem

Currently, when using actions/checkout, specifying a ref that does not exist causes the action to fail. In some workflows, it would be more efficient if, when the specified branch does not exist, a new branch could be automatically created from the default branch.

Proposed Solution

I propose adding an auto-create option to actions/checkout. This option would allow the action to:

  1. Checkout the default branch (e.g., main) if the specified ref does not exist.
  2. Create a new branch with the specified ref from the default branch.

This behavior would only occur when the auto-create option is enabled, keeping the current behavior unchanged by default.

Example YAML

- name: Checkout code
  uses: actions/checkout@v3
  with:
    ref: 'feature-branch'
    auto-create: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions