Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8779b82

Browse files
authored
backwards compat for GITHUB_TOKEN from env (#133)
* backwards compat for GITHUB_TOKEN from env * update changelog
1 parent d2a05f5 commit 8779b82

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.1.8
2+
3+
- fix backwards compatibility with `GITHUB_TOKEN` resolution. `GITHUB_TOKEN` is no resolved first from an env varibale and then from and input [#133](https://github.com/softprops/action-gh-release/pull/133)
4+
15
## 0.1.7
26

37
- allow creating draft releases without a tag [#95](https://github.com/softprops/action-gh-release/pull/95)

‎__tests__/util.test.ts‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ describe("util", () => {
9696
input_target_commitish: undefined
9797
});
9898
});
99-
});
100-
describe("parseConfig", () => {
99+
101100
it("parses basic config with commitish", () => {
102101
assert.deepStrictEqual(
103102
parseConfig({
@@ -119,6 +118,53 @@ describe("util", () => {
119118
}
120119
);
121120
});
121+
it("prefers GITHUB_TOKEN over token input for backwards compatibility", () => {
122+
assert.deepStrictEqual(
123+
parseConfig({
124+
INPUT_DRAFT: "false",
125+
INPUT_PRERELEASE: "true",
126+
GITHUB_TOKEN: "env-token",
127+
INPUT_TOKEN: "input-token"
128+
}),
129+
{
130+
github_ref: "",
131+
github_repository: "",
132+
github_token: "env-token",
133+
input_body: undefined,
134+
input_body_path: undefined,
135+
input_draft: false,
136+
input_prerelease: true,
137+
input_files: [],
138+
input_name: undefined,
139+
input_tag_name: undefined,
140+
input_fail_on_unmatched_files: false,
141+
input_target_commitish: undefined
142+
}
143+
);
144+
});
145+
it("uses input token as the source of GITHUB_TOKEN by default", () => {
146+
assert.deepStrictEqual(
147+
parseConfig({
148+
INPUT_DRAFT: "false",
149+
INPUT_PRERELEASE: "true",
150+
INPUT_TOKEN: "input-token"
151+
}),
152+
{
153+
github_ref: "",
154+
github_repository: "",
155+
github_token: "input-token",
156+
input_body: undefined,
157+
input_body_path: undefined,
158+
input_draft: false,
159+
input_prerelease: true,
160+
input_files: [],
161+
input_name: undefined,
162+
input_tag_name: undefined,
163+
input_fail_on_unmatched_files: false,
164+
input_target_commitish: undefined
165+
}
166+
);
167+
});
122168
it("parses basic config with draft and prerelease", () => {
123169
assert.deepStrictEqual(
124170
parseConfig({

‎dist/index.js‎

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

‎src/util.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getInput } from "@actions/core";
21
import * as glob from "glob";
32
import { lstatSync, readFileSync } from "fs";
43

@@ -42,7 +41,7 @@ export const parseInputFiles = (files: string): string[] => {
4241

4342
export const parseConfig = (env: Env): Config => {
4443
return {
45-
github_token: getInput("token") || env.GITHUB_TOKEN || "",
44+
github_token: env.GITHUB_TOKEN || env.INPUT_TOKEN || "",
4645
github_ref: env.GITHUB_REF || "",
4746
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
4847
input_name: env.INPUT_NAME,

0 commit comments

Comments
 (0)