added new project script
This commit is contained in:
		
							parent
							
								
									e2d2864949
								
							
						
					
					
						commit
						ea06fb48d7
					
				@ -2,7 +2,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Joomla CMS.
 | 
					Joomla CMS.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Make sure the projectName is set correctly, it's very important.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1. Clone me ```git clone git@git.nickyeoman.com:nick/joomla.git projectName```
 | 
					1. Clone me ```git clone git@git.nickyeoman.com:nick/joomla.git projectName```
 | 
				
			||||||
1. mv env.sample .env
 | 
					1. cd projectName
 | 
				
			||||||
1. vi .env
 | 
					1. Setup your .env file ```mv env.sample .env``` then edit with your favorite editor.
 | 
				
			||||||
 | 
					1. bash bin 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
1. sudo docker-compose up -d
 | 
					1. sudo docker-compose up -d
 | 
				
			||||||
							
								
								
									
										49
									
								
								bin/new_project.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								bin/new_project.sh
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
				
			|||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PROJECTNAME=$(pwd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Verify the .env file exists
 | 
				
			||||||
 | 
					if [ ! -f ".env" ]; then
 | 
				
			||||||
 | 
					  echo "Error: The .env file does not exist."
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Load environment variables from .env file
 | 
				
			||||||
 | 
					set -o allexport
 | 
				
			||||||
 | 
					source .env
 | 
				
			||||||
 | 
					set +o allexport
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Verify the required environment variables are set
 | 
				
			||||||
 | 
					if [ -z "$GITEA_API_URL" ] || [ -z "$ACCESS_TOKEN" ]; then
 | 
				
			||||||
 | 
					  echo "Error: Please make sure GITEA_API_URL and ACCESS_TOKEN are set in the .env file."
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Create the repository using Gitea API
 | 
				
			||||||
 | 
					RESPONSE=$(curl -sSL -H "Authorization: token $ACCESS_TOKEN" -H "Content-Type: application/json" -X POST -d "{\"name\":\"$PROJECTNAME\"}" "$GITEA_API_URL/api/v1/user/repos")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Check the API response and handle errors
 | 
				
			||||||
 | 
					STATUS=$(echo "$RESPONSE" | jq -r '.message')
 | 
				
			||||||
 | 
					if [ "$STATUS" != "null" ]; then
 | 
				
			||||||
 | 
					  echo "Error: Failed to create $PROJECTNAME repository. $STATUS"
 | 
				
			||||||
 | 
					  exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo "Repository '$PROJECTNAME' created successfully on Gitea."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Remove existing Git repository information
 | 
				
			||||||
 | 
					rm -rf .git
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Initialize a new Git repository
 | 
				
			||||||
 | 
					git init
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Add new remote repository
 | 
				
			||||||
 | 
					git remote add origin "$GITEA_API_URL/$PROJECTNAME.git"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Confirm remote configuration
 | 
				
			||||||
 | 
					git remote -v
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Commit existing changes
 | 
				
			||||||
 | 
					git add .
 | 
				
			||||||
 | 
					git commit -m "Initial commit of new project $PROJECTNAME"
 | 
				
			||||||
 | 
					git push -u origin master
 | 
				
			||||||
@ -6,3 +6,8 @@ MYSQL_ROOT_PASSWORD=REPLACEME
 | 
				
			|||||||
MYSQL_USER=REPLACEME
 | 
					MYSQL_USER=REPLACEME
 | 
				
			||||||
MYSQL_PASSWORD=REPLACEME
 | 
					MYSQL_PASSWORD=REPLACEME
 | 
				
			||||||
MYSQL_DATABASE=REPLACEME
 | 
					MYSQL_DATABASE=REPLACEME
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# GITEA
 | 
				
			||||||
 | 
					GITEA_API_URL=<your_gitea_api_url>
 | 
				
			||||||
 | 
					ACCESS_TOKEN=<your_access_token>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user