forked from sahil-sagwekar2652/GitHub-Automation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sahil-sagwekar2652/main
sahil-sagwekar2652#21 Fix the Readme (GsSoc'23)
- Loading branch information
Showing
3 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
# GitHub Personal Access Token | ||
TOKEN="YOUR_PERSONAL_ACCESS_TOKEN" | ||
|
||
# Repository name | ||
REPO_NAME="new-repo" | ||
|
||
# Repository description | ||
REPO_DESCRIPTION="This is a new repository" | ||
|
||
# API endpoint | ||
API_URL="https://api.github.com/user/repos" | ||
|
||
# Create repository payload | ||
PAYLOAD=$(cat << EOF | ||
{ | ||
"name": "$REPO_NAME", | ||
"description": "$REPO_DESCRIPTION", | ||
"private": false, | ||
"auto_init": false | ||
} | ||
EOF | ||
) | ||
|
||
# Send POST request to create repository | ||
response=$(curl -s -H "Authorization: token $TOKEN" -d "$PAYLOAD" "$API_URL") | ||
|
||
# Check response status | ||
if [[ "$(echo "$response" | jq -r '.message')" == "Validation Failed" ]]; then | ||
echo "Error: Failed to create repository." | ||
echo "Reason: $(echo "$response" | jq -r '.errors[0].message')" | ||
else | ||
echo "Repository '$REPO_NAME' created successfully." | ||
fi |