🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

@actions/github

Package Overview
Dependencies
Maintainers
6
Versions
18
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.1
latest
Source
npm
Version published
Weekly downloads
1.4M
-25.94%
Maintainers
6
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

github

FAQs

Package last updated on 07 May 2025

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