Skip to content
upload-cloud

GitHub Action

Push Dir

v1.0.2 Latest version

Push Dir

upload-cloud

Push Dir

Cleanly push directory contents to a branch

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Push Dir

uses: casperdcl/push-dir@v1.0.2

Learn more about this action in casperdcl/push-dir

Choose a version

GitHub Action: Push Directory

Test

Cleanly push directory contents to a branch. Particularly useful for gh-pages deployment.

Example

    steps:
      - uses: actions/checkout@v3
      - run: build_site_command --output-dir static_site
      - uses: casperdcl/push-dir@v1
        with:
          message: update static site
          branch: gh-pages
          dir: static_site
          history: false
          cname: my.domain.com
          nojekyll: true

Why

Perfect for e.g. gh-pages deployment.

  • Supports pushing the contents of a directory to a branch
  • Supports discarding branch history
  • Uses a blazing fast native GitHub composite action
  • Has the entirety of the code in a single file, making it very easy to review

The main alternatives GitHub Actions gh-pages-deploy and github-push currently do not offer the benefits above.

Other features (supported by some of the alternatives) include:

  • Custom committer name & email
  • Custom commit message
  • Force pushing
  • CNAME & .nojekyll conveniences for GitHub pages

Inputs

message:
  description: Commit message
  required: true
branch:
  description: Branch to push to
  required: true
dir:
  description: Directory to push
  default: .
  required: false
force:
  description: Set to "true" to force push
  required: false
history:
  description: |
    Set to "false" to discard any prior commits on the `branch`
    (Note: "false" will override `force` to "true")
  default: true
  required: false
cname:
  description: Text to inject into a `CNAME` file
  default: ''
  required: false
nojekyll:
  description: Set to "true" to add a `.nojekyll` file
  required: false
name:
  description: Git committer name
  required: false
email:
  description: Git committer email
  required: false