Skip to content

Commit

Permalink
implemented constants for env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Bullrich committed Jan 17, 2024
1 parent 7c1030c commit 2dcdd81
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ jobs:
with:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PROVIDER_URL: "wss://polkadot-collectives-rpc.polkadot.io" # Optional.
start-date: ${{ steps.date.outputs.last }}
START_DATE: ${{ steps.date.outputs.last }}
```
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const PROVIDER_URL = process.env.PROVIDER_URL || "wss://polkadot-collectives-rpc.polkadot.io";
export const POLKADOT_APPS_URL = `https://polkadot.js.org/apps/?rpc=${encodeURIComponent(PROVIDER_URL)}#/`;
export const START_DATE = process.env.START_DATE || "0";
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as githubActions from "@actions/github";
import { envVar } from "@eng-automation/js";
import type { IssueCommentCreatedEvent } from "@octokit/webhooks-types";

import { START_DATE } from "./constants";
import { handleCommand } from "./handle-command";
import { cron } from "./rfc-cron";
import { GithubReactionType } from "./types";
Expand All @@ -13,8 +14,7 @@ export async function run(): Promise<void> {
const octokitInstance = githubActions.getOctokit(envVar("GH_TOKEN"));
if (context.eventName === "schedule" || context.eventName === "workflow_dispatch") {
const { owner, repo } = context.repo;
const startDate = core.getInput("start-date") ?? "0";
return await cron(new Date(startDate), owner, repo, octokitInstance);
return await cron(new Date(START_DATE), owner, repo, octokitInstance);
} else if (context.eventName !== "issue_comment") {
throw new Error("The action is expected to be run on 'issue_comment' events only.");
}
Expand Down
3 changes: 2 additions & 1 deletion src/rfc-cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import fetch from "node-fetch";

import { extractRfcResult } from "./parse-RFC";
import { OctokitInstance } from "./types";
import { PROVIDER_URL } from "./constants";

const getReferendaData = async (track: number): Promise<ReferendaData> => {
const url = `https://collectives.subsquare.io/api/fellowship/referenda/${track}.json`;
Expand Down Expand Up @@ -56,7 +57,7 @@ export const getAllPRs = async (
};

export const getAllRFCRemarks = async (startDate: Date): Promise<{ url: string; remark: string }[]> => {
const wsProvider = new WsProvider("wss://polkadot-collectives-rpc.polkadot.io");
const wsProvider = new WsProvider(PROVIDER_URL);
try {
const api = await ApiPromise.create({ provider: wsProvider });
// We fetch all the members
Expand Down

0 comments on commit 2dcdd81

Please sign in to comment.