Skip to content

About

GitHub Action to push more then one file via GitHub API with signed commits.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

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.
⚠️ concurrent commits to the same branch are retried up to 5 attempts, each attempt rebuilt on top of the latest head. If the branch moves on every attempt the run fails with an error instead of overwriting the other run's change.
⚠️ only a ref update rejected because the branch moved is retried; a protected branch rejection, a missing branch, or any other 422 fails immediately.
⚠️ a branch force-pushed backwards during a retry cannot be detected: the new head is an ancestor of the commit being pushed, so the API accepts the update (there is no conditional write) and the run re-adds the removed commits.

What's new

  • First implementation is currently tested
  • Runtime upgraded to Node 24 (GitHub Action runtime and package engine)
  • zx upgraded to latest major (8.x)
  • Concurrent commits to the same branch are retried up to 5 attempts instead of overwriting each other (#9)
  • The action skips with a notice when no staged file is selected (#9)

Usage

- uses: tyriis/multi-file-commit@v1.0.0
  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.
    # If no staged file matches, the action skips, makes no commit, and leaves the `sha` output empty.
    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

About

GitHub Action to push more then one file via GitHub API with signed commits.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages