Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a create_secrets script inorder to reduce user error whilst creating github_secrets.py #103

Closed
wants to merge 9 commits into from
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This repository hosts scripts written in bash and python to automate common Git/

<a name="tech"></a>
## Tech 🖥️
[![My Skills](https://skillicons.dev/icons?i=py,bash,git,github&perline=4)](https://skillicons.dev)
[![My Skills](https://skillicons.dev/icons?i=py,go,bash,git,github&perline=5)](https://skillicons.dev)


## 🏗️ Installation
Expand All @@ -47,6 +47,7 @@ To install and configure the project on your system locally, use the command men

##### Requirements:
- [Git Bash](https://git-scm.com/downloads) installed on your computer.
- [Go](https://github.com/golang/go) and [gum](https://github.com/charmbracelet/gum#installation)
- **GitHub personal access token**. (Go to your GitHub profile -> Settings -> Developer settings -> Personal Access Tokens -> Create new token with all the repository permissions)


Expand All @@ -55,15 +56,8 @@ To install and configure the project on your system locally, use the command men
- ### Step 1:
Fork and clone the repository locally.

- ### Step 2:
Create a ```github_secrets.py``` file in the ./scripts folder and define the following variables inside it.

```py
GITHUB_API_TOKEN = "Your GitHub personal access token"
USERNAME = "Your GitHub username"
```

- ### Step 3:
- ### Step 2:

#### Add the project path to the PATH variable (Recommended)

Expand All @@ -88,6 +82,32 @@ $ echo 'export PATH=$PATH''":'"$(pwd)"'/scripts''"' >> ~/.bash_profile
$ cp -r /scripts/* /usr/bin/
```

- ### Step 3:

**Create a ```github_secrets.py``` file in the ./scripts folder and define the variables using.**

```sh
create_secrets
```

#### create_secrets. (Execute this in the scripts directory only)

![](https://github.com/Squashedapricot/GitHub-Automation-scripts/blob/main/gum_gifs/create_key.gif)

#### to update secrets use the same command.
![](https://github.com/Squashedapricot/GitHub-Automation-scripts/blob/main/gum_gifs/update_key.gif)

**(I Used "./" as I didn't add the scripts to my shell's environment variable)**

**! tested only on Arch Linux BTW**
<p style="text-align:center;font-size:1.75rem">OR</p>
Manually add

```py
GITHUB_API_TOKEN = "Your GitHub personal access token"
USERNAME = "Your GitHub username"
```

## How to use
After the installation is complete then the 'create_repo' command should execute in any directory.

Expand Down
Binary file added gum_gifs/create_key.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gum_gifs/update_key.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions scripts/create_secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

TOKEN=$(gum input --placeholder "Git Token" --password)
NAME=$(gum input --placeholder "Username")


# echo -e "Well that's something,""$TOKEN"

if [ ! -f 'github_secrets.py' ]
then
gum spin --spinner dot --title "Creating github_secrets.py" -- sleep 2 && echo "GITHUB_API_TOKEN = ""\"$TOKEN"\" >> github_secrets.py && echo "USERNAME = ""\"$NAME"\" >> github_secrets.py
else
gum confirm "Do you want to remove the old file?" && rm 'github_secrets.py' && echo "GITHUB_API_TOKEN = ""\"$TOKEN"\" >> github_secrets.py && echo "USERNAME = ""\"$NAME"\" >> github_secrets.py || echo "file no removed"
fi

# echo "GITHUB_API_TOKEN = ""$TOKEN" >> name.txt
# echo "USERNAME = ""$NAME" >> name.txt