Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@actions/github

Package Overview
Dependencies
Maintainers
5
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@actions/github

Actions github lib

  • 6.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
increased by2.99%
Maintainers
5
Weekly downloads
 
Created

What is @actions/github?

The @actions/github npm package provides a set of tools and functionalities to interact with GitHub within GitHub Actions. It allows for the automation of GitHub workflows, including repository management, issue handling, and pull requests among other GitHub operations. This package leverages the GitHub API and the GitHub Actions environment to enable developers to create sophisticated CI/CD workflows.

What are @actions/github's main functionalities?

Creating an issue

This code demonstrates how to create a new issue in a GitHub repository using the @actions/github package. It utilizes the `getOctokit` method to authenticate with the GitHub API using a token and then calls the `create` method on `issues` to create a new issue.

const github = require('@actions/github');
const core = require('@actions/core');

async function createIssue() {
  const token = core.getInput('repo-token');
  const octokit = github.getOctokit(token);

  const response = await octokit.rest.issues.create({
    owner: 'owner-name',
    repo: 'repo-name',
    title: 'New Issue Title',
    body: 'Issue description.'
  });

  console.log(response.url);
}

createIssue();

Commenting on a pull request

This example shows how to automatically comment on a pull request using the @actions/github package. It first checks if the GitHub Actions context has a pull request payload, extracts the pull request number, and then uses the `createComment` method to post a comment.

const github = require('@actions/github');
const core = require('@actions/core');

async function commentOnPR() {
  const token = core.getInput('repo-token');
  const octokit = github.getOctokit(token);
  const context = github.context;

  if (context.payload.pull_request) {
    const prNumber = context.payload.pull_request.number;

    const response = await octokit.rest.issues.createComment({
      owner: context.repo.owner,
      repo: context.repo.repo,
      issue_number: prNumber,
      body: 'Automated comment on PR.'
    });

    console.log(response.url);
  }
}

commentOnPR();

Other packages similar to @actions/github

Keywords

FAQs

Package last updated on 10 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc