Skip to content

NRM10101/github-api-integration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub API Integration

A Rust-based API service that provides seamless integration with GitHub's API. This project offers endpoints for repository management, file operations, and branch handling. Built with Axum framework, it provides a robust and efficient way to interact with GitHub repositories programmatically.

Features

  • Repository creation and management
  • Branch creation and management
  • File content retrieval and upload
  • Environment-based branch handling
  • Secure token-based authentication

Tech Stack

  • Rust
  • Axum (Web Framework)
  • Octocrab (GitHub API Client)
  • Tokio (Async Runtime)

Prerequisites

  • Rust (latest stable version)
  • Cargo (Rust's package manager)
  • GitHub Personal Access Token

Installation

  1. Clone the repository:
git clone https://github.com/your-username/github-api-integration.git
cd github-api-integration
  1. Set up your GitHub token:
# PowerShell
$env:GITHUB_TOKEN="your-github-token"

# Bash
export GITHUB_TOKEN="your-github-token"
  1. Build and run the project:
cargo run

The server will start at http://localhost:3000

API Endpoints

1. Get File Contents

GET /api/github-file?url=<github-file-url>

Retrieves the contents of a file from a GitHub repository.

2. Create Repository and Upload File

POST /api/github/repo

Creates a new repository and uploads a file to a specified branch.

Request body:

{
    "owner": "your-username",
    "repo": "repository-name",
    "env": "development",
    "main_branch": "main",
    "file_name": "example.txt",
    "file_content": "Hello, World!"
}

Environment Variables

  • GITHUB_TOKEN: Your GitHub Personal Access Token (Required)

Error Handling

The API returns standardized responses in the following format:

{
    "success": boolean,
    "message": string,
    "data": object | null,
    "error": string | null
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

About

A Rust-based API service that provides seamless integration with GitHub's API. This project offers endpoints for repository management, file operations, and branch handling. Built with Axum framework, it provides a robust and efficient way to interact with GitHub repositories programmatically.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages