CreateFile creates a new file in a repository at the given path and returns the commit and file metadata. GitHub API docs: https://docs.github.com/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents meta:operation PUT /repos/{owner}/{repo}/contents/{path}
(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions)
| 254 | // |
| 255 | //meta:operation PUT /repos/{owner}/{repo}/contents/{path} |
| 256 | func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error) { |
| 257 | u := fmt.Sprintf("repos/%v/%v/contents/%v", owner, repo, path) |
| 258 | req, err := s.client.NewRequest(ctx, "PUT", u, opts) |
| 259 | if err != nil { |
| 260 | return nil, nil, err |
| 261 | } |
| 262 | |
| 263 | var createResponse *RepositoryContentResponse |
| 264 | resp, err := s.client.Do(req, &createResponse) |
| 265 | if err != nil { |
| 266 | return nil, resp, err |
| 267 | } |
| 268 | |
| 269 | return createResponse, resp, nil |
| 270 | } |
| 271 | |
| 272 | // UpdateFile updates a file in a repository at the given path and returns the |
| 273 | // commit and file metadata. Requires the blob SHA of the file being updated. |