Two GitHub steps work with files in a repository. GitHub · Create or update a file — Commits a file to a branch — writes a file, as a commit, whether or not it exists yet. GitHub · Get a file — A file's text, and the file itself for later steps — reads one.

Who can do this

Workspace Admins and Editors, on every plan. Viewers see the steps' settings but cannot change them.

Before you start

A GitHub connection whose token has the repository and Contents: Read and write (classic: repo). To change a file under .github/workflows, the token also needs Workflows: Read and write (classic: workflow). See Connect GitHub.

Steps

Create or update a file:

  1. Select + where the step should go. In the step picker, open Apps, select GitHub, then Create or update a file. Or search GitHub.
  2. In Connection, choose your GitHub connection.
  3. In Repository, choose the repository — for example consulace/billing-service.
  4. In Path, the file's path in the repository — docs/release-notes.md. Folders that do not exist yet are made.
  5. Give what the file should hold, one of:
    • In Content, the text — The file's text — or leave it empty and give a file below.
    • Or under Or a file, select Add a file and drag in a file from an earlier step — A file from an earlier step. When both are given, the file wins.
  6. Optional: in Branch, choose the branch. Empty uses the repository's default branch.
  7. In Commit message, type the message — for example Release notes for {{ trigger.tag }}.
  8. Select Run this step to try it. This makes a real commit.

Get a file:

  1. In the step picker, under GitHub, select Get a file, and choose the Connection and Repository.
  2. In Path, the file's path — README.md.
  3. Optional: in Branch, choose a branch. Empty reads the default branch.
  4. Select Run this step to try it.

Output

Create or update a file:

Field What it is
path The file's path.
sha GitHub's id for this version of the file.
url The file's page on GitHub.
commit The commit the step made.
created true when the file was new, false when it replaced one.

Get a file:

Field What it is
path, sha The file's path and GitHub's id for this version of it.
name The file's own name — README.md.
size Its size in bytes.
text Its contents, when it is text. A picture, PDF or other file that is not text has no text.

The file itself comes with the item too, as file, keeping its own name — README.md. Drag it from Data from earlier steps into a later step's file setting, such as Attachments or Or a file. See Pass files between steps.

Good to know

  • Create or update a file replaces the whole file. It does not add to the end. To add a line, Get a file first, then write its text with the new line.
  • With Content empty and no file, the file is committed empty.
  • Get a file reads files up to 100 MB. Over 1 MB, GitHub does not send the contents with the file's details, so Bizomate fetches them separately.
  • A folder is not a file. Give a path to a folder, and both steps stop with docs is a folder, not a file.
  • A branch protected in GitHub may refuse commits that do not go through a pull request.
  • Each item runs the step once. Ten items make ten commits.

If something goes wrong

What you see Why What to do
Path is empty when the step ran — an earlier step may not have given the value it names. The path came out empty. Check the values it reads.
Commit message is empty when the step ran — … No commit message. Type one.
GitHub refused: Not Found. Get a file: no file at that path on that branch. Either step: the token cannot see the repository, or the branch does not exist. Check the path — it is case-sensitive — and the branch.
GitHub refused: Resource not accessible by personal access token. Check the connection's details on Connections. The token lacks Contents: Read and write — or Workflows for a file under .github/workflows. Add the permission in GitHub.
GitHub refused: … refusing to allow a Personal Access Token to create or update workflow … without workflow scope. A classic token without workflow, writing under .github/workflows. Tick workflow on the token.
GitHub refused: … protected branch … The branch only takes changes through a pull request. Commit to another branch, then use Create a pull request.