How to use the @actions/github.context.repo function in @actions/github

To help you get started, we’ve selected a few @actions/github examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JasonEtco / action-record / src / register-models.ts View on Github external
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.
  }
}
github actions / create-release / src / create-release.js View on Github external
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,
github JasonEtco / action-record / src / model.ts View on Github external
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)
github ziishaned / jest-reporter-action / index.js View on Github external
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"
github ziishaned / jest-reporter-action / index.js View on Github external
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(
github JasonEtco / action-record / src / instance.ts View on Github external
async destroy () {
    return octokit.issues.update({
      ...context.repo,
      issue_number: this.issue_number,
      state: 'closed'
    })
  }
}
github mathieudutour / github-tag-action / src / main.ts View on Github external
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);
  }
}

@actions/github

Actions github lib

MIT
Latest version published 6 months ago

Package Health Score

93 / 100
Full package analysis