Flask API Project GitHub Integration
Overview
This section outlines the steps to integrate the Python Flask API project with GitHub and manage the deployment workflow.
Steps
Associate VS Code with GitHub:
Install VS Code if it is not already installed.
Install the GitHub Pull Requests and Issues extension in VS Code.
Authenticate your GitHub account with VS Code. This typically involves generating a Personal Access Token (PAT) from GitHub and adding it to VS Code.
Workflow:
Make changes to your files in VS Code.
Commit those changes to the appropriate branch (e.g., `develop/staging` or `release`).
Push your changes to the GitHub repository. If working on `master`, your files will be updated in the `master` branch.
Synchronizing Your Local Git Folder with GitHub
1. Initialize the Git Repository
Open VS Code and open your project folder (`C:\Users\unapa\OneDrive\Documentos\git`).
Open the integrated terminal in VS Code (Ctrl + ` ).
Navigate to your project directory if not already there:
cd C:\Users\unapa\OneDrive\Documentos\git
git init
2. Stage and Commit Your Files
git status
git add .
git commit -m "Initial commit"
3. Connect to Your GitHub Repository
Go to your GitHub account and create a new repository. You can name it git to match your local folder.
Do not initialize the repository with a README, .gitignore, or license since you've already set up your local repository.
After creating the repository, GitHub will show you the commands to connect your local repo to this remote one. You'll need to add the remote repository
URL:
git remote add origin https://github.com/fipharraguerre/git.git
git remote -v
4. Push Your Local Commits to GitHub
5. Verify the Changes on GitHub
Now your local project is synchronized with your GitHub repository! From here on, you can make changes to your files, commit them, and push them to GitHub.
Deploying to the Staging Server:
Set up a Git hook or a Continuous Integration/Continuous Deployment (CI/CD) pipeline to automatically pull changes from the `staging` branch onto your server.
Use tools like GitHub Actions, Jenkins, or a cron job to automate this process.
Containerization and Production:
Once everything is validated on the staging server, merge the changes into the `release` branch.
The `release` branch can trigger a Docker build process, creating a container for the Flask app.
Notes
This setup allows for safe development and testing in the staging environment before deploying a containerized version in production.