Skip to content

Commit

Permalink
Deploy Production Code for Commit 749e6dc 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed Nov 28, 2023
1 parent 749e6dc commit e3d554d
Show file tree
Hide file tree
Showing 31 changed files with 527 additions and 136 deletions.
32 changes: 28 additions & 4 deletions lib/constants.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Describes the action interface.
*/
export interface ActionInterface {
/** Deployment token. */
token?: string;
Expand All @@ -16,6 +19,9 @@ export interface ActionInterface {
/** Fetches organization level sponsors if true. */
organization: boolean;
}
/**
* Gets the action configuration.
*/
export declare const action: {
token: string;
template: string;
Expand All @@ -26,7 +32,9 @@ export declare const action: {
fallback: string;
organization: boolean;
};
/** Describes the response from the GitHub GraphQL query. */
/**
* Describes the sponsor object.
*/
export interface Sponsor {
sponsorEntity: {
name: string | null;
Expand All @@ -37,16 +45,22 @@ export interface Sponsor {
createdAt: string;
privacyLevel: PrivacyLevel;
tier: {
monthlyPriceInCents: number;
monthlyPriceInCents?: number;
};
}
/**
* Describes the response from the GitHub GraphQL query.
*/
export interface SponsorshipsAsMaintainer {
totalCount: number;
pageInfo: {
endCursor: string;
};
nodes: Sponsor[];
}
/**
* Describes the response from the GitHub GraphQL query.
*/
export interface GitHubResponse {
data: {
organization?: {
Expand All @@ -57,19 +71,29 @@ export interface GitHubResponse {
};
};
}
/** Types for the required action parameters. */
/**
* Describes the action interface.
*/
export declare type RequiredActionParameters = Pick<ActionInterface, 'token'>;
/**
* Privacy levels for the sponsorship.
*/
export declare enum PrivacyLevel {
PUBLIC = "PUBLIC",
PRIVATE = "PRIVATE"
}
/** Status codes for the action. */
/**
* Statuses for the action.
*/
export declare enum Status {
SUCCESS = "success",
FAILED = "failed",
RUNNING = "running",
SKIPPED = "skipped"
}
/**
* URLs used within the action.
*/
export declare enum Urls {
GITHUB_API = "https://api.github.com"
}
14 changes: 12 additions & 2 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.Urls = exports.Status = exports.PrivacyLevel = exports.action = void 0;
const core_1 = require("@actions/core");
const util_1 = require("./util");
// Required action data that gets initialized when running within the GitHub Actions environment.
/**
* Gets the action configuration.
*/
exports.action = {
token: (0, core_1.getInput)('token'),
template: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('template'))
Expand All @@ -26,19 +28,27 @@ exports.action = {
? (0, core_1.getInput)('organization').toLowerCase() === 'true'
: false
};
/**
* Privacy levels for the sponsorship.
*/
var PrivacyLevel;
(function (PrivacyLevel) {
PrivacyLevel["PUBLIC"] = "PUBLIC";
PrivacyLevel["PRIVATE"] = "PRIVATE";
})(PrivacyLevel = exports.PrivacyLevel || (exports.PrivacyLevel = {}));
/** Status codes for the action. */
/**
* Statuses for the action.
*/
var Status;
(function (Status) {
Status["SUCCESS"] = "success";
Status["FAILED"] = "failed";
Status["RUNNING"] = "running";
Status["SKIPPED"] = "skipped";
})(Status = exports.Status || (exports.Status = {}));
/**
* URLs used within the action.
*/
var Urls;
(function (Urls) {
Urls["GITHUB_API"] = "https://api.github.com";
Expand Down
32 changes: 30 additions & 2 deletions lib/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,35 @@ function run(configuration) {
const settings = Object.assign({}, configuration);
try {
(0, core_1.info)(`
GitHub Sponsors Readme Action 💖
██████╗ ██╗████████╗██╗ ██╗██╗ ██╗██████╗
██╔════╝ ██║╚══██╔══╝██║ ██║██║ ██║██╔══██╗
██║ ███╗██║ ██║ ███████║██║ ██║██████╔╝
██║ ██║██║ ██║ ██╔══██║██║ ██║██╔══██╗
╚██████╔╝██║ ██║ ██║ ██║╚██████╔╝██████╔╝
╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
███████╗██████╗ ██████╗ ███╗ ██╗███████╗ ██████╗ ██████╗ ███████╗
██╔════╝██╔══██╗██╔═══██╗████╗ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝
███████╗██████╔╝██║ ██║██╔██╗ ██║███████╗██║ ██║██████╔╝███████╗
╚════██║██╔═══╝ ██║ ██║██║╚██╗██║╚════██║██║ ██║██╔══██╗╚════██║
███████║██║ ╚██████╔╝██║ ╚████║███████║╚██████╔╝██║ ██║███████║
╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
██████╗ ███████╗ █████╗ ██████╗ ███╗ ███╗███████╗
██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝
██████╔╝█████╗ ███████║██║ ██║██╔████╔██║█████╗
██╔══██╗██╔══╝ ██╔══██║██║ ██║██║╚██╔╝██║██╔══╝
██║ ██║███████╗██║ ██║██████╔╝██║ ╚═╝ ██║███████╗
╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝
█████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗
██╔══██╗██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║
███████║██║ ██║ ██║██║ ██║██╔██╗ ██║
██╔══██║██║ ██║ ██║██║ ██║██║╚██╗██║
██║ ██║╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
🚀 Getting Started Guide: https://github.com/JamesIves/github-sponsors-readme-action
❓ Discussions / Q&A: https://github.com/JamesIves/github-sponsors-readme-action/discussions
🔧 Report a Bug: https://github.com/JamesIves/github-sponsors-readme-action/issues
Expand All @@ -49,7 +76,8 @@ function run(configuration) {
: status === constants_1.Status.SUCCESS
? 'The data was successfully retrieved and saved! ✅ 💖'
: `Unable to locate markers in your file. Please check the documentation and try again. ⚠️`}`);
(0, core_1.setOutput)('sponsorship-status', status);
(0, core_1.exportVariable)('sponsorshipStatus', status);
(0, core_1.setOutput)('sponsorshipStatus', status);
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions lib/template.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export declare function getSponsors(action: ActionInterface): Promise<GitHubResp
* Generates the sponsorship template.
*/
export declare function generateTemplate(response: GitHubResponse, action: ActionInterface): string;
/**
* Generates the updated file with the attached sponsorship template.
*/
export declare function generateFile(response: GitHubResponse, action: ActionInterface): Promise<Status>;
9 changes: 7 additions & 2 deletions lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ function generateTemplate(response, action) {
/* Appends the template, the API call returns all users regardless of if they are hidden or not.
In an effort to respect a users decision to be anonymous we filter these users out. */
let filteredSponsors = sponsorshipsAsMaintainer.nodes.filter((user) => user.privacyLevel !== constants_1.PrivacyLevel.PRIVATE &&
user.tier.monthlyPriceInCents >= action.minimum);
(user.tier.monthlyPriceInCents ? user.tier.monthlyPriceInCents : 0) >=
action.minimum);
if (action.maximum > 0) {
filteredSponsors = filteredSponsors.filter((user) => user.tier.monthlyPriceInCents <= action.maximum);
filteredSponsors = filteredSponsors.filter((user) => (user.tier.monthlyPriceInCents ? user.tier.monthlyPriceInCents : 0) <=
action.maximum);
}
/** If there are no valid sponsors then we return the provided fallback. */
if (!filteredSponsors.length) {
Expand All @@ -109,6 +111,9 @@ function generateTemplate(response, action) {
return template;
}
exports.generateTemplate = generateTemplate;
/**
* Generates the updated file with the attached sponsorship template.
*/
function generateFile(response, action) {
return __awaiter(this, void 0, void 0, function* () {
try {
Expand Down
4 changes: 2 additions & 2 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions node_modules/@actions/core/lib/core.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 17 additions & 18 deletions node_modules/@actions/core/lib/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e3d554d

Please sign in to comment.