actions-github

Crates.ioactions-github
lib.rsactions-github
version0.2.0
sourcesrc
created_at2024-05-24 14:21:20.222142
updated_at2024-05-27 16:17:06.557118
descriptionA rust translation of the helper library @actions/github to build GitHub actions using rust
homepage
repositoryhttps://github.com/Bullrich/rusty-actions-github
max_upload_size
id1251168
size24,104
Javier Bullrich (Bullrich)

documentation

https://docs.rs/actions-github/latest/actions_github/

README

Rusty-Actions

A rust translation of @actions/github.

GitHub Actions

Find the documentation here.

Crates.io Total Downloads

Installation

cargo add actions-github

Latest version available is latest version

Usage

// Obtain the context from the action worker
use actions_github::context::get_context;
use actions_github::logger;

logger::info("Obtaining context");
let data = get_context().unwrap();

logger::debug(format!("Event is {}", data.event_name).as_str());

// Produce an output
set_output("is_pr", (ctx.event_name == "pull_request").to_string());

Works well with octocrab:

use actions_github::core::{get_input, set_output};
use actions_github::context::get_context;
use octocrab::Octocrab;

let token = get_input("GITHUB_TOKEN").unwrap();

let crab = Octocrab::builder().personal_token(token).build();
octocrab::initialise(crab.unwrap());

let context = get_context();
let org = context.repo.owner;
let repo = context.repo.repo;

let pulls = octocrab::instance().pulls(owner, repo).list()

// Output how many PRs are in the repository
set_output("PRs", pulls.len().to_string());
Commit count: 20

cargo fmt