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
{{ message }}
This repository was archived by the owner on Jan 19, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+46-2Lines changed: 46 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@
7
7
This action makes it easy to quickly write a script in your workflow that
8
8
uses the GitHub API and the workflow run context.
9
9
10
-
To use this action, provide an input named `script` that contains the body of an asynchronous function call.
10
+
To use this action, provide an input named `script` that contains the body of an asynchronous function call.
11
11
The following arguments will be provided:
12
12
13
13
-`github` A pre-authenticated
@@ -83,6 +83,47 @@ output of a github-script step. For some workflows, string encoding is preferred
83
83
script: return "I will be string (not JSON) encoded!"
84
84
```
85
85
86
+
## Retries
87
+
88
+
By default, requests made with the `github` instance will not be retried. You can configure this with the `retries` option:
89
+
90
+
```yaml
91
+
- uses: actions/github-script@v6
92
+
id: my-script
93
+
with:
94
+
result-encoding: string
95
+
retries: 3
96
+
script: |
97
+
github.rest.issues.get({
98
+
issue_number: context.issue.number,
99
+
owner: context.repo.owner,
100
+
repo: context.repo.repo,
101
+
})
102
+
```
103
+
104
+
In this example, request failures from `github.rest.issues.get()` will be retried up to 3 times.
105
+
106
+
You can also configure which status codes should be exempt from retries via the `retry-exempt-status-codes` option:
107
+
108
+
```yaml
109
+
- uses: actions/github-script@v6
110
+
id: my-script
111
+
with:
112
+
result-encoding: string
113
+
retries: 3
114
+
retry-exempt-status-codes: 400,401
115
+
script: |
116
+
github.rest.issues.get({
117
+
issue_number: context.issue.number,
118
+
owner: context.repo.owner,
119
+
repo: context.repo.repo,
120
+
})
121
+
```
122
+
123
+
By default, the following status codes will not be retried: `400, 401, 403, 404, 422`[(source)](https://github.com/octokit/plugin-retry.js/blob/9a2443746c350b3beedec35cf26e197ea318a261/src/index.ts#L14).
124
+
125
+
These retries are implemented using the [octokit/plugin-retry.js](https://github.com/octokit/plugin-retry.js) plugin. The retries use [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to space out retries. ([source](https://github.com/octokit/plugin-retry.js/blob/9a2443746c350b3beedec35cf26e197ea318a261/src/error-request.ts#L13))
126
+
86
127
## Examples
87
128
88
129
Note that `github-token` is optional in this action, and the input is there
@@ -354,8 +395,11 @@ jobs:
354
395
To import an ESM file, you'll need to reference your script by an absolute path and ensure you have a `package.json` file with `"type": "module"` specified.
355
396
356
397
For a script in your repository `src/print-stuff.js`:
398
+
357
399
```js
358
-
export default function printStuff() { console.log('stuff') }
0 commit comments