Skip to content

Commit

Permalink
Merge branch 'main' into PIMS-2106-nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
LawrenceLau2020 authored Nov 13, 2024
2 parents 72960f4 + f573d93 commit 21b6e28
Show file tree
Hide file tree
Showing 33 changed files with 2,058 additions and 1,280 deletions.
21 changes: 5 additions & 16 deletions .github/config/dep-report.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
// Check package.json files for dependency updates.
packageJsonPaths: ["react-app", "express-api"],

// Do not report on the following packages.
ignorePackages: {
// Path to package.json file.
"src/react-app": [], // Add names of packages such as ["typescript"].
"src/express-api": ["xlsx"],
},
// List of packages to ignore when reporting in jira ticket(s)
ignoreList: ["xlsx"],

// Sets what levels of dependencies to include in the jira ticket(s)
depLevels: ["minor", "major"],

// The env variables below are used to update the create_tickets.py script

// used to determine what updates to post
LEVEL_FLAGS: "MINOR MAJOR",
// sets what JIRA board to post and pull from
JIRA_BOARD: "PIMS",
// each Jira board has a different issue type for subtasks
JIRA_SUBTASK: "10003",
// epic links are technically a custom field with this specific id and ticket number (for PIMS)
JIRA_EPIC: "10014, PIMS-450"
}
21 changes: 0 additions & 21 deletions .github/helpers/github-api/create-and-close-existing-issue.mjs

This file was deleted.

142 changes: 72 additions & 70 deletions .github/helpers/github-api/github-api-requests.mjs
Original file line number Diff line number Diff line change
@@ -1,47 +1,16 @@
/**
* Reusable functions for making requests to the GitHub REST API.
* @author Brady Mitchell <[email protected] | [email protected]>
* API Documentation: https://octokit.github.io/rest.js/v19#usage
* @editor Taylor Friesen <[email protected]>
* API Documentation: https://docs.github.com/en/rest
*
* THIS FILE DOES NOT NEED TO BE EDITED, but you can add more functions if desired.
* Place within .github/helpers/github-api/
*
* - Be sure to include the env variables from below!
*
* @example GitHub Actions Workflow:
* jobs:
* github-api:
* runs-on: ubuntu-22.04
* container:
* image: node:20.2-bullseye-slim
*
* steps:
* # Checkout branch.
* - name: Checkout repository
* uses: actions/checkout@v3
*
* # Get Repo Owner and Repo Name.
* - name: Set repo information
* run: |
* echo "REPO_OWNER=$(echo ${{ github.repository }} | cut -d / -f 1)" >> $GITHUB_ENV
* echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d / -f 2)" >> $GITHUB_ENV
*
* # Install @octokit/rest npm package for making GitHub rest API requests.
* - name: Install @octokit/rest npm
* run: npm i @octokit/rest
*
* # Run Node Script that calls functions from github-api-requests.js.
* - name: Node Script
* env:
* GITHUB_OWNER: ${{ env.REPO_OWNER }}
* GITHUB_REPO: ${{ env.REPO_NAME }}
* GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
* run: node .github/helpers/script.js
*/

import { Octokit } from '@octokit/rest';
import { Octokit } from "@octokit/rest";
const { GITHUB_TOKEN, GITHUB_REPOSITORY } = process.env;
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split('/');
const [GITHUB_OWNER, GITHUB_REPO] = GITHUB_REPOSITORY.split("/");

// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: GITHUB_TOKEN });
Expand All @@ -50,64 +19,97 @@ const octokit = new Octokit({ auth: GITHUB_TOKEN });
* Create an Issue with the GitHub REST API.
* @param {string} title - The title for the new issue.
* @param {string} body - The content body for the new issue.
* @returns request.data - Data returned by the request.
* @returns - response - returned response from github.
* @example
* createIssue('My Issue', 'An example issue');
*/
export async function createIssue(title, body) {
const request = await octokit.rest.issues.create({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
title,
body,
});
console.log(request.data);
return request;
const response = await octokit.rest.issues.create({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
title,
body,
});
//console.log("create issue: ", response.data);
return response;
}

/**
* Close an Issue with the GitHub REST API.
* @param {number} issue_number - The id for a GitHub Issue.
* @returns request.data - Data returned by the request.
* @returns - response - returned response from github.
* @example
* closeIssue(1044);
*/
export async function closeIssue(issue_number) {
const request = await octokit.rest.issues.update({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number,
state: 'closed',
});
console.log(request.data);
return request;
const response = await octokit.rest.issues.update({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number,
state: "closed",
});
//console.log("close issue: ", response.data);
return response;
}

/**
* Get issue number from title, and create a request to add a comment.
* @param {*} issueNumber - the number for the issue to comment on
* @param {*} issueComment - the comment to add
* @returns - response - returned response from github.
* @example
* addComment(1234, 'An example comment');
*/
export async function addComment(issueNumber, issueComment) {
const response = await octokit.rest.issues.createComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
issue_number: issueNumber,
body: issueComment,
});
//console.log("add comment: ", response.data);
return response;
}

/**
* Close a comment on an issue by referencing the ID
* @param {*} commentID - the number associated with a comment
* @returns - response - returned response from github.
* @example
* deleteComment(1234);
*/
export async function deleteComment(commentID) {
const response = await octokit.rest.issues.deleteComment({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
comment_id: commentID,
});
//console.log("delete comment: ", response.data);
return response;
}

/**
* Find an Issue's ID number with the GitHub REST API, given a title.
* @param {string} title - The title of the issue to search for.
* @param {string} state - (optional, default=open) Search for all, open, or closed issues.
* @returns issue.number or null
* @returns response from Github
* @example
* findIssueByTitle('My Issue');
*/
export async function findIssueByTitle(title, state = 'open') {
const { data: issues } = await octokit.rest.issues.listForRepo({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
state, // Get issues that are 'open', 'closed' or 'all'.
});

for (const issue of issues) {
if (issue.title === title) {
return issue.number;
}
}
return null; // Return null if no issue found.
export async function findIssues(state = "open") {
const response = await octokit.rest.issues.listForRepo({
owner: GITHUB_OWNER,
repo: GITHUB_REPO,
state, // Get issues that are 'open', 'closed' or 'all'.
});
//console.log("found issue: ", response.data);
return response;
}

export default {
createIssue,
closeIssue,
findIssueByTitle,
createIssue,
closeIssue,
addComment,
deleteComment,
findIssues,
};
Loading

0 comments on commit 21b6e28

Please sign in to comment.