You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removed the `commitFilesFromBuffers` and `commitFilesFromDirectory` APIs. These APIs were simple wrappers over the core `commitChangesFromBase64` API, which should be used instead. Read the file and pass the base64-encoded content to `commitChangesFromBase64``fileChanges` directly. For example:
All functions in this library that interact with the GitHub API require an octokit client that can execute GraphQL. If you are writing code that is designed to be run from within a GitHub Action, this can be done using the `@actions.github` library:
43
+
All functions in this library that interact with the GitHub API require an octokit client that can execute GraphQL. If you are writing code that is designed to be run from within a GitHub Action, this can be done using the `@actions/github` library:
To allow for you to produce smaller bundle sizes, the functionality exposed in this package is grouped into specific modules that only import the packages required for their use. We recommend that you import from the specific modules rather than the root of the package.
54
-
55
51
## API
56
52
57
53
All the functions below accept a single object as its argument, and share the following base arguments:
@@ -77,8 +73,66 @@ All the functions below accept a single object as its argument, and share the fo
77
73
}
78
74
```
79
75
76
+
### `commitFilesFromBase64`
77
+
78
+
> Works in Node.js and browsers
79
+
80
+
This function will add or delete specific files from a repository's branch based on the given `fileChanges` argument.
81
+
82
+
In addition to `CommitFilesBasedArgs`, this function has the following arguments:
83
+
84
+
```ts
85
+
{
86
+
/**
87
+
* The current branch, tag or commit that the new branch should be based on.
88
+
*/
89
+
base: GitBase;
90
+
/**
91
+
* The file paths, relative to git root, to add or delete from the branch on GitHub.
92
+
*/
93
+
fileChanges: {
94
+
/**
95
+
* File paths, relative to git root, to add to the repo. Content is a base64-encoded string.
96
+
*/
97
+
additions?: { path: string; content: string }[];
98
+
/**
99
+
* File paths, relative to git root, to remove from the repo.
This function will take an existing repository on your filesystem (defaulting to the current working directory). This function is good to use if you're usually working within the context of a git repository, such as after running `@actions/checkout` in github actions.
83
137
84
138
In addition to `CommitFilesBasedArgs`, this function has the following arguments:
This function will add or delete specific files from a repository's branch based on files found on the local filesystem. This is good to use when there are specific files that need to be updated on a branch, or if many changes may have been made locally, but only some files need to be pushed.
172
-
173
-
In addition to `CommitFilesBasedArgs`, this function has the following arguments:
174
-
175
-
```ts
176
-
{
177
-
/**
178
-
* The current branch, tag or commit that the new branch should be based on.
179
-
*/
180
-
base: GitBase;
181
-
/**
182
-
* The directory to consider the root of the repository when calculating
183
-
* file paths
184
-
*/
185
-
cwd: string;
186
-
/**
187
-
* The file paths, relative to {@linkworkingDirectory},
188
-
* to add or delete from the branch on GitHub.
189
-
*/
190
-
fileChanges: {
191
-
/** File paths, relative to {@linkworkingDirectory}, to remove from the repo. */
192
-
additions?:string[];
193
-
/** File paths, relative to the repository root, to remove from the repo. */
// Commit the changes to package.json and package-lock.json
208
-
// based on the main branch
209
-
awaitcommitFilesFromDirectory({
210
-
octokit,
211
-
...context.repo,
212
-
branch: "new-branch-to-create",
213
-
message: "[chore] do something",
214
-
base: {
215
-
branch: "main",
216
-
},
217
-
cwd: "foo/bar",
218
-
fileChanges: {
219
-
additions: ["package-lock.json", "package.json"],
220
-
},
221
-
});
222
-
223
-
// Push just the index.html file to a new branch called docs, based off the tag v1.0.0
224
-
awaitcommitFilesFromDirectory({
225
-
octokit,
226
-
...context.repo,
227
-
branch: "docs",
228
-
message: "[chore] do something",
229
-
force: true, // Overwrite any existing branch
230
-
base: {
231
-
tag: "v1.0.0",
232
-
},
233
-
cwd: "some-dir",
234
-
fileChanges: {
235
-
additions: ["index.html"],
236
-
},
237
-
});
238
-
```
239
-
240
-
### `commitFilesFromBuffers`
241
-
242
-
This function will add or delete specific files from a repository's branch based on Node.js `Buffers` that can be any binary data in memory. This is useful for when you want to make changes to a repository / branch without cloning a repo or interacting with a filesystem.
243
-
244
-
In addition to `CommitFilesBasedArgs`, this function has the following arguments:
245
-
246
-
```ts
247
-
{
248
-
/**
249
-
* The current branch, tag or commit that the new branch should be based on.
250
-
*/
251
-
base: GitBase;
252
-
/**
253
-
* The file changes, relative to the repository root, to make to the specified branch.
0 commit comments