Skip to content

tyriis/multi-file-commit

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

pre-commit taskfile

Multi File Commit

This action commit multiple files over the GitHub API by pushing blobs and adding them to a tree. It commit all staged files.

Table of Contents

User Story

As a user I want to push and commit multiple files in 1 commit. if doing it via git push, there is no way to sign the the commit in an action context. Of course I want to use only signed commits restriction on my branches (and I dont want to bypass the restriction to protect my software supply chain).

The Idea

It is possible to create blobs and tree to create a commit via GitHub API. I found the solution to the problem here: https://siddharthav.medium.com/push-multiple-files-under-a-single-commit-through-github-api-f1a5b0b283ae

Thanks for your work Siddhartha Varma.

Limitations

⚠️ it cannot be used on empty repositories.
⚠️ parallel commits on the same file lead to a race condition where previous changes are overwritten.

What's new

  • First implementation is currently tested

Usage

- uses: tyriis/[email protected]
  with:
    # Repository name with owner. For example, actions/checkout
    # Default: ${{ github.repository }}
    repository: ''

    # The branch you want to push the commit
    # Default: ${{ github.ref_name }}
    ref: ''

    # Personal access token (PAT) used to fetch the repository. The PAT is configured
    # with the local git config, which enables your scripts to run GitHub API commands.
    # Default: ${{ github.token }}
    token: ''

    # The commit message for the commit.
    message: ''

    # A list of files to commit, prevent other staged files to be commited.
    # Example: src/main.mjs,src/main.spec.js
    # If not set all staged files are considered for commit.
    files: ''

    # In case you want to tag your commit, just pass a tag reference and this action will do the work for you.
    tag: ''

License

The scripts and documentation in this project are released under the MIT License