Skip to content

Commit

Permalink
fix: revert "feat: add kebab-case support with.github-token (#319)"
Browse files Browse the repository at this point in the history
This reverts commit 71dd0c1.
Se regression in #320
  • Loading branch information
gr2m committed May 31, 2023
1 parent 71dd0c1 commit 6a5cb73
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 62 deletions.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ It does not require any configuration, but instead reads [the `GITHUB_TOKEN` env
- [`createActionAuth()`](#createactionauth)
- [`auth()`](#auth)
- [Authentication object](#authentication-object)
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-optionsorauthhookrequest-options)
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
- [Find more information](#find-more-information)
- [License](#license)

Expand Down Expand Up @@ -62,15 +62,6 @@ steps:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```

or named `github-token` using [`with:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith)

```yml
steps:
- name: My action
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
```

or named `token` using [`with:`](https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepswith)

```yml
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const createActionAuth: StrategyInterface<
const definitions = [
process.env.GITHUB_TOKEN,
process.env.INPUT_GITHUB_TOKEN,
process.env["INPUT_GITHUB-TOKEN"],
process.env.INPUT_TOKEN,
].filter(Boolean);

Expand All @@ -37,7 +36,7 @@ export const createActionAuth: StrategyInterface<

if (definitions.length > 1) {
throw new Error(
"[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB-TOKEN`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth"
"[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth"
);
}

Expand Down
51 changes: 1 addition & 50 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ afterEach(() => {
delete process.env.GITHUB_ACTION;
delete process.env.GITHUB_TOKEN;
delete process.env.INPUT_GITHUB_TOKEN;
delete process.env["INPUT_GITHUB-TOKEN"];
delete process.env.INPUT_TOKEN;
});

Expand All @@ -25,7 +24,7 @@ test("README example", async () => {
});
});

test("README example using with.github_token", async () => {
test("README example using with:", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env.INPUT_GITHUB_TOKEN =
"v1.1234567890abcdef1234567890abcdef12345678";
Expand All @@ -40,21 +39,6 @@ test("README example using with.github_token", async () => {
});
});

test("README example using with.github-token", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env["INPUT_GITHUB-TOKEN"] =
"v1.1234567890abcdef1234567890abcdef12345678";

const auth = createActionAuth();
const authentication = await auth();

expect(authentication).toEqual({
type: "token",
token: "v1.1234567890abcdef1234567890abcdef12345678",
tokenType: "installation",
});
});

test("README example using with.token", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env.INPUT_TOKEN = "v1.1234567890abcdef1234567890abcdef12345678";
Expand Down Expand Up @@ -96,39 +80,6 @@ test("both GITHUB_TOKEN and INPUT_GITHUB_TOKEN set", async () => {
}
});

test("both GITHUB_TOKEN and INPUT_GITHUB-TOKEN set", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env.GITHUB_TOKEN = "v1.1234567890abcdef1234567890abcdef12345678";
process.env["INPUT_GITHUB-TOKEN"] =
"v1.1234567890abcdef1234567890abcdef12345678";

try {
createActionAuth();
throw new Error("Should not resolve");
} catch (error: any) {
expect(error.message).toMatch(
/\[@octokit\/auth-action\] The token variable is specified more than once/i
);
}
});

test("both INPUT_GITHUB_TOKEN and INPUT_GITHUB-TOKEN set", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env.INPUT_GITHUB_TOKEN =
"v1.1234567890abcdef1234567890abcdef12345678";
process.env["INPUT_GITHUB-TOKEN"] =
"v1.1234567890abcdef1234567890abcdef12345678";

try {
createActionAuth();
throw new Error("Should not resolve");
} catch (error: any) {
expect(error.message).toMatch(
/\[@octokit\/auth-action\] The token variable is specified more than once/i
);
}
});

test("both GITHUB_TOKEN and INPUT_TOKEN set", async () => {
process.env.GITHUB_ACTION = "my-action";
process.env.GITHUB_TOKEN = "v1.1234567890abcdef1234567890abcdef12345678";
Expand Down

0 comments on commit 6a5cb73

Please sign in to comment.