backwards compat for GITHUB_TOKEN from env (#133)
* backwards compat for GITHUB_TOKEN from env * update changelog
This commit is contained in:
parent
d2a05f5e5a
commit
8779b820d9
4 changed files with 54 additions and 5 deletions
|
@ -1,3 +1,7 @@
|
|||
## 0.1.8
|
||||
|
||||
- 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)
|
||||
|
||||
## 0.1.7
|
||||
|
||||
- allow creating draft releases without a tag [#95](https://github.com/softprops/action-gh-release/pull/95)
|
||||
|
|
|
@ -96,8 +96,7 @@ describe("util", () => {
|
|||
input_target_commitish: undefined
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("parseConfig", () => {
|
||||
|
||||
it("parses basic config with commitish", () => {
|
||||
assert.deepStrictEqual(
|
||||
parseConfig({
|
||||
|
@ -119,6 +118,53 @@ describe("util", () => {
|
|||
}
|
||||
);
|
||||
});
|
||||
it("prefers GITHUB_TOKEN over token input for backwards compatibility", () => {
|
||||
assert.deepStrictEqual(
|
||||
parseConfig({
|
||||
INPUT_DRAFT: "false",
|
||||
INPUT_PRERELEASE: "true",
|
||||
GITHUB_TOKEN: "env-token",
|
||||
INPUT_TOKEN: "input-token"
|
||||
}),
|
||||
{
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "env-token",
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
input_prerelease: true,
|
||||
input_files: [],
|
||||
input_name: undefined,
|
||||
input_tag_name: undefined,
|
||||
input_fail_on_unmatched_files: false,
|
||||
input_target_commitish: undefined
|
||||
}
|
||||
);
|
||||
});
|
||||
it("uses input token as the source of GITHUB_TOKEN by default", () => {
|
||||
assert.deepStrictEqual(
|
||||
parseConfig({
|
||||
INPUT_DRAFT: "false",
|
||||
INPUT_PRERELEASE: "true",
|
||||
INPUT_TOKEN: "input-token"
|
||||
}),
|
||||
{
|
||||
github_ref: "",
|
||||
github_repository: "",
|
||||
github_token: "input-token",
|
||||
input_body: undefined,
|
||||
input_body_path: undefined,
|
||||
input_draft: false,
|
||||
input_prerelease: true,
|
||||
input_files: [],
|
||||
input_name: undefined,
|
||||
input_tag_name: undefined,
|
||||
input_fail_on_unmatched_files: false,
|
||||
input_target_commitish: undefined
|
||||
}
|
||||
);
|
||||
});
|
||||
it("parses basic config with draft and prerelease", () => {
|
||||
assert.deepStrictEqual(
|
||||
parseConfig({
|
||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,3 @@
|
|||
import { getInput } from "@actions/core";
|
||||
import * as glob from "glob";
|
||||
import { lstatSync, readFileSync } from "fs";
|
||||
|
||||
|
@ -42,7 +41,7 @@ export const parseInputFiles = (files: string): string[] => {
|
|||
|
||||
export const parseConfig = (env: Env): Config => {
|
||||
return {
|
||||
github_token: getInput("token") || env.GITHUB_TOKEN || "",
|
||||
github_token: env.GITHUB_TOKEN || env.INPUT_TOKEN || "",
|
||||
github_ref: env.GITHUB_REF || "",
|
||||
github_repository: env.INPUT_REPOSITORY || env.GITHUB_REPOSITORY || "",
|
||||
input_name: env.INPUT_NAME,
|
||||
|
|
Loading…
Reference in a new issue