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

Open
#1,920 0 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
32/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
typescript
Domain
ci-cd

Research direction

No files, tests, or entry points are named in the issue. Start by locating actions/checkout's ref-resolution flow, then verify that the proposed option preserves current failure behavior when disabled and creates the requested branch from the repository's default branch when enabled.

Written by the indexing model from the issue text.

Description

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
Dominant language
TypeScript
Stars
8.9k
Forks
2.8k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from actions/checkout

All issues in actions/checkout

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.