- Develop locally with React.
- Set up GitHub repo.
- Configure GCP Services.
- Test your site is working locally.
- Connect custom domain.
- Set up automation.
- Make changes via GitHub
Develop locally with React.
# Create React app locally first
npx create-react-app my-website
cd my-website
git init
git add .
git commit -m "Initial commit"Set up GitHub repo. Connect local repo to github
# Connect local repo to GitHub
git remote add origin https://github.com/yourusername/your-repo-name.git
git branch -M main
git push -u origin main
Repo structure
my-website/
├── public/
├── src/
├── build/ (generated)
├── .github/workflows/ (CI/CD)
└── package.json
3.Configure GCP Services.
3.1. GCP Project Creation
Go to Google Cloud Console
- Create new project
- Enable billing account
3.2. Required Services
Enable these services:
- Cloud Build (CI/CD)
- Cloud Storage (Hosting)
- IAM (Permissions)
4.React App configuration.
4.1. Create build script in package.json
{
"name": "my-website",
"homepage": "https://your-domain.com",
"scripts": {
"build": "react-scripts build",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}
}
Top comments (0)