write_github_file: Write a file to a branch

Description Usage Arguments Value Examples

Description

These functions writes files to a repository by creating a new commit on the specified branch. write_github_file() writes the content to a text file, using readr::write_file(); write_github_lines() writes to a text file, using readr::write_lines() and write_github_csv() writes a CSV file, using readr::write_csv().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
write_github_file(content, path, branch, message, repo, author, committer, ...)

write_github_lines(
  content,
  path,
  branch,
  message,
  repo,
  author,
  committer,
  ...
)

write_github_csv(content, path, branch, message, repo, author, committer, ...)

Arguments

content

(character or data.frame) The content of the file.

path

(string) The path to create the file at, within the repository.

branch

(string) The name of the branch to make the new commit on.

message

(string) The commit message.

repo

(string) The repository specified in the format: owner/repo.

author

(list, optional) A the name and email address of the user who wrote the changes in the commit.

committer

(list, optional) A the name and email address of the user who created the commit.

...

Parameters passed to readr::write_file(), readr::write_lines() or readr::write_csv().

Value

write_github_file(), write_github_lines() and write_github_csv() return a list of the commit properties.

Commit Properties:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 

  write_github_file(
    content = "# This is a new file\\n\\n Created by githapi",
    path    = "new-file.md",
    branch  = "main",
    message = "Created a new file with write_github_file()",
    repo    = "ChadGoymer/githapi"
  )

  write_github_lines(
    content   = c("# This is a new file", "", "Created by githapi"),
    path      = "new-file.md",
    branch    = "main",
    message   = "Created a new file with write_github_lines()",
    repo      = "ChadGoymer/githapi"
  )

  write_github_csv(
    content = tibble(letters = LETTERS, numbers = 1:26),
    path    = "new-file.md",
    branch  = "main",
    message = "Updated an existing file with write_github_csv()",
    repo    = "ChadGoymer/githapi"
  )


## End(Not run)

ChadGoymer/githapi documentation built on Oct. 22, 2021, 10:56 a.m.