Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function createModelLabel (name: string) {
// Create new label if it doesn't exist
try {
await octokit.issues.createLabel({
...context.repo,
name,
color: colorHash.hex(name)
})
} catch (err) {
core.debug(err.message)
// TODO: Handle errors. If this throws because the label
// already exists, ignore the error. Else, throw.
}
}
async function run() {
try {
// Get authenticated GitHub client (Ocktokit): https://github.com/actions/toolkit/tree/master/packages/github#usage
const github = new GitHub(process.env.GITHUB_TOKEN);
// Get owner and repo from context of payload that triggered the action
const { owner, repo } = context.repo;
// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const tagName = core.getInput('tag_name', { required: true });
// This removes the 'refs/tags' portion of the string, i.e. from 'refs/tags/v1.10.15' to 'v1.10.15'
const tag = tagName.replace('refs/tags/', '');
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', '');
const body = core.getInput('body', { required: false });
const draft = core.getInput('draft', { required: false }) === 'true';
const prerelease = core.getInput('prerelease', { required: false }) === 'true';
// Create a release
// API Documentation: https://developer.github.com/v3/repos/releases/#create-a-release
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-create-release
const createReleaseResponse = await github.repos.createRelease({
owner,
return this.hooks.save(async () => {
// Create the new issue
const newIssue = await octokit.issues.create({
...context.repo,
title: `[${this.name}]: ${id}`,
body: Model.jsonToBody(data),
labels: [this.name]
})
// Return the new instance
return new Instance(this, {
...data,
created_at: newIssue.data.created_at,
issue_number: newIssue.data.number
})
}, opts)
}, opts)
const main = async () => {
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
const githubToken = core.getInput("github-token");
const testCommand = core.getInput("test-command") || "npx jest";
const githubClient = new GitHub(githubToken);
const commitPRs = await githubClient.repos.listPullRequestsAssociatedWithCommit(
{
repo: repoName,
owner: repoOwner,
commit_sha: context.sha
}
);
const prNumber = commitPRs.data[0].number;
const codeCoverage = execSync(testCommand).toString();
let coveragePercentage = execSync(
"npx coverage-percentage ./coverage/lcov.info --lcov"
const main = async () => {
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
const githubToken = core.getInput("github-token");
const testCommand = core.getInput("test-command") || "npx jest";
const githubClient = new GitHub(githubToken);
const commitPRs = await githubClient.repos.listPullRequestsAssociatedWithCommit(
{
repo: repoName,
owner: repoOwner,
commit_sha: context.sha
}
);
const prNumber = commitPRs.data[0].number;
const codeCoverage = execSync(testCommand).toString();
let coveragePercentage = execSync(
async destroy () {
return octokit.issues.update({
...context.repo,
issue_number: this.issue_number,
state: 'closed'
})
}
}
core.debug(`New tag: ${newTag}`);
if (preRelease) {
core.debug(
"This branch is not a release branch. Skipping the tag creation."
);
return;
}
const octokit = new GitHub(core.getInput("github_token"));
core.debug(`Pushing new tag to the repo`);
await octokit.git.createRef({
...context.repo,
ref: `refs/tags/${newTag}`,
sha: GITHUB_SHA
});
} catch (error) {
core.setFailed(error.message);
}
}