Github API integration project /Automating Github

This project automates the process of retrieving and displaying user access information for any GitHub repository. By leveraging the GitHub API, this shell script can provide detailed insights into who has read, write, and admin access to a repository….


This content originally appeared on DEV Community and was authored by Kartik

This project automates the process of retrieving and displaying user access information for any GitHub repository. By leveraging the GitHub API, this shell script can provide detailed insights into who has read, write, and admin access to a repository. This tool is particularly useful for DevOps engineers and project managers who need to audit repository access regularly.

How It Works

Setting Up: Start by exporting your GitHub username and personal access token as environment variables to keep them secure.

Running the Script: Execute the script with the desired repository owner and name as command line arguments.

Output Interpretation: The script uses the curl command to make API requests and jq to parse the JSON response, displaying users with specific access levels.

If you want to create the project, follow these detailed steps:

Step 1: Create a GitHub Organization and Repository
-Create a GitHub Organization:
-Go to GitHub.
-Click on your profile picture in the top-right corner and select "Your organizations."
-Click "New organization."
-Choose "Create a free organization" and fill in the required details such as organization name and email.

Create a Repository:
-Within your organization, click "New" to create a new repository.
-Name the repository and choose the visibility (public or private).

Step 2: Prepare Your Environment
-Install Required Tools:
Ensure you have curl installed. This tool will be used to make API requests.
-Install jq for parsing JSON data:
sudo apt install jq -y

Step 3: Write the Shell Script or clone it:
-Create the Shell Script :
Create a new shell script file, for example, list_users.sh.

Write the code from https://github.com/kartik-paliwa1/shell-script-for-API-integration/blob/main/list-users.sh

-Or you can directly clone it:
Write the below command to clone the repo.

git clone https://github.com/kartik-paliwa1/shell-script-for-API-integration

-Then open repo:
cd shell-script-for-API-integration

-Write your github user-name and your token:
export GITHUB_USERNAME="your_username"
export GITHUB_TOKEN="your_token"

Step 4: Execute the Script
-Set the File Permissions:
chmod 777 list_users.sh

-Run the Script:
Execute the script with your repository details:
./list_users.sh 'Organisation-name' 'Repo-name'

Step 5: Verify the Output:
The script should output the list of users with read access to the specified repository. For example:
Output:
kartik-paliwa1 has access to shell-script-for-API-integration

Credits: Learned this project from YT channel Abhishek.Veeramalla


This content originally appeared on DEV Community and was authored by Kartik


Print Share Comment Cite Upload Translate Updates
APA

Kartik | Sciencx (2024-07-24T19:55:55+00:00) Github API integration project /Automating Github. Retrieved from https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/

MLA
" » Github API integration project /Automating Github." Kartik | Sciencx - Wednesday July 24, 2024, https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/
HARVARD
Kartik | Sciencx Wednesday July 24, 2024 » Github API integration project /Automating Github., viewed ,<https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/>
VANCOUVER
Kartik | Sciencx - » Github API integration project /Automating Github. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/
CHICAGO
" » Github API integration project /Automating Github." Kartik | Sciencx - Accessed . https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/
IEEE
" » Github API integration project /Automating Github." Kartik | Sciencx [Online]. Available: https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/. [Accessed: ]
rf:citation
» Github API integration project /Automating Github | Kartik | Sciencx | https://www.scien.cx/2024/07/24/github-api-integration-project-automating-github/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.