Skip to content

Commit 94d0a81

Browse files
committed
fix issues with octokit auth
Actions should now forward the GITHUB_TOKEN env var correctly. Might need to fallback on secrets.GITHUB_TOKEN as well.
1 parent ba8aa9c commit 94d0a81

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

package-lock.json

Lines changed: 27 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"@actions/exec": "^1.0.4",
66
"@actions/io": "^1.0.2",
77
"@octokit/action": "^3.18.0",
8+
"@octokit/auth-action": "^2.0.0",
89
"@octokit/core": "^3.5.1",
910
"@octokit/plugin-rest-endpoint-methods": "^5.13.0",
1011
"@terascope/fetch-github-release": "^0.8.7",

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {addPath, info, getInput, setFailed, setOutput} from "@actions/core"
22
import {Octokit} from "@octokit/action";
3+
const { createActionAuth } = require("@octokit/auth-action");
34
import {restEndpointMethods} from "@octokit/plugin-rest-endpoint-methods";
45
import {downloadRelease} from "@terascope/fetch-github-release";
56
import {RestEndpointMethodTypes} from "@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types";
@@ -139,7 +140,8 @@ async function install(releaseId: number, asset: ReleaseAsset, restorePath: stri
139140
*/
140141
export async function run(): Promise<void> {
141142
const RestOctokit = Octokit.plugin(restEndpointMethods);
142-
const gitHubApi = new RestOctokit();
143+
const auth = createActionAuth();
144+
const gitHubApi = new RestOctokit({ auth: await auth() });
143145

144146
const release = await findVersion(gitHubApi, getInput("version"));
145147
const asset = findAsset(release.assets, GITHUB_RELEASE_ASSET_NAME);

0 commit comments

Comments
 (0)