use input instead of env to receive github token

Co-authored-by: Platane <me@platane.me>
This commit is contained in:
Awayume
2023-10-09 16:04:10 +09:00
committed by Platane
parent 01fa6d7aac
commit c9644d3dfa
8 changed files with 19 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
import * as fs from "fs";
import * as path from "path";
import * as core from "@actions/core";
import { generateContributionSnake } from "../generateContributionSnake";
import { parseOutputsOption } from "../outputsOptions";
import { config } from "dotenv";
@@ -33,7 +34,7 @@ it(
const outputs = parseOutputsOption(entries);
const results = await generateContributionSnake("platane", outputs, {
githubToken: process.env.GITHUB_TOKEN!,
githubToken: core.getInput("github_token"),
});
expect(results[0]).toBeDefined();

View File

@@ -12,7 +12,8 @@ import { parseOutputsOption } from "./outputsOptions";
core.getInput("svg_out_path"),
]
);
const githubToken = process.env.GITHUB_TOKEN!;
const githubToken =
process.env.GITHUB_TOKEN ?? core.getInput("github_token");
const { generateContributionSnake } = await import(
"./generateContributionSnake"

View File

@@ -1,6 +1,7 @@
import path from "path";
import HtmlWebpackPlugin from "html-webpack-plugin";
import webpack from "webpack";
import * as core from "@actions/core";
import { getGithubUserContribution } from "@snk/github-user-contribution";
import { config } from "dotenv";
import type { Configuration as WebpackConfiguration } from "webpack";
@@ -16,7 +17,8 @@ const webpackDevServerConfiguration: WebpackDevServerConfiguration = {
const userName: string = req.params.userName;
res.send(
await getGithubUserContribution(userName, {
githubToken: process.env.GITHUB_TOKEN!,
githubToken:
process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
})
);
});

View File

@@ -1,3 +1,4 @@
import * as core from "@actions/core";
import { getGithubUserContribution } from "@snk/github-user-contribution";
import { VercelRequest, VercelResponse } from "@vercel/node";
import nodeFetch from "node-fetch";
@@ -12,7 +13,7 @@ export default async (req: VercelRequest, res: VercelResponse) => {
res.statusCode = 200;
res.json(
await getGithubUserContribution(userName as string, {
githubToken: process.env.GITHUB_TOKEN!,
githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
})
);
} catch (err) {

View File

@@ -1,18 +1,14 @@
import * as core from "@actions/core";
import { getGithubUserContribution } from "..";
import { config } from "dotenv";
config({ path: __dirname + "/../../../.env" });
describe("getGithubUserContribution", () => {
const promise = getGithubUserContribution("platane", {
githubToken: process.env.GITHUB_TOKEN!,
githubToken: process.env.GITHUB_TOKEN ?? core.getInput("github_token"),
});
it("should resolve", async () => {
console.log(
"process.env.GITHUB_TOKEN",
process.env.GITHUB_TOKEN?.replace(/\d/g, "x")
);
await promise;
});