-
Notifications
You must be signed in to change notification settings - Fork 1
/
github_commands.sh
executable file
·48 lines (37 loc) · 1.18 KB
/
github_commands.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
############################################
# AUTHOR : FAREED SAYED
# DATE : 01 OCTOBER 2024
# TO EXECUTE PROPER GITHUB
############################################
# Prompt for commit message
read -p "Enter commit message: " commit_message
# Check if the user provided a commit message
if [ -z "$commit_message" ]; then
echo "Commit message cannot be empty. Exiting."
exit 1
fi
# Prompt for branch name
read -p "Enter branch name: " branch_name
# Switch to the branch or create it if it doesn't exist
git checkout "$branch_name" || git checkout -b "$branch_name"
# Add changes to staging
git add .
# Commit changes with user-provided message
git commit -m "$commit_message"
# Pull latest changes from origin branch
git pull origin "$branch_name"
# Add changes to staging again (in case there were updates from pull)
git add .
# Commit changes again with user-provided message
git commit -m "$commit_message"
# Run detect-secrets scan
echo "Running secret check..."
if detect-secrets scan; then
echo "No secrets found."
else
echo "Secrets detected! Please resolve the issues before pushing."
exit 1
fi
# Push changes to origin branch
git push origin "$branch_name"