Welcome to the Cloud Resume API Project! This project showcases how to build and deploy a serverless API using Google Cloud Functions, Firestore, and GitHub Actions. The API serves resume data in JSON format.
Before getting started, ensure you have the following:
- Google Cloud Platform account
- GitHub account
- Go to the Google Cloud Console and create a new project.
- Enable the Cloud Functions API and Firestore for your project.
- In the Google Cloud Console, create a new Firestore database.
- Create a collection named
resume-database
. - Add your resume data as a document inside the
resume-database
collection.
-
Create a new repository on GitHub for your project.
-
Clone the repository to your local machine:
git clone https://github.com/YOUR-USERNAME/YOUR-REPO-NAME.git
- Add Cloud Function Code In the root directory of your cloned repository, create a new file named index.js.
Add your Cloud Function code into index.js:
javascript Copy code
// Your Cloud Function code here
- Create package.json In the root directory, create a package.json file.
Add the following content to the package.json:
json Copy code
{
"name": "cloud-resume-api",
"version": "1.0.0",
"dependencies": {
"@google-cloud/functions-framework": "^3.1.3",
"@google-cloud/firestore": "^6.4.2"
}
}
- Set Up GitHub Actions Workflow In your GitHub repository, create a new folder and file at .github/workflows/deploy-function.yml. Add the following configuration to deploy-function.yml:
yaml Copy code
# GitHub Actions workflow for deploying Cloud Functions
# Your GitHub Actions workflow configuration here
- Add GitHub Secrets In your GitHub repository, navigate to Settings > Secrets > Actions. Add a new secret named GCP_SA_KEY with the value of your Google Cloud service account key that has permissions to deploy Cloud Functions.
- Commit & Push Changes Commit and push your changes to GitHub:
bash Copy code
git add .
git commit -m "Initial commit"
git push
This will trigger your GitHub Actions workflow to deploy the Cloud Function automatically.
🔧 Test Your API After a successful deployment, test your API by sending a request to the Cloud Function URL provided in the Google Cloud Console.
📚 Additional Resources Google Cloud Functions Documentation GitHub Actions Documentation