User Tools

Site Tools


flask_api_project_github_integration

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

  1. Associate VS Code with GitHub:
    1. Install VS Code if it is not already installed.
    2. Install the GitHub Pull Requests and Issues extension in VS Code.
    3. Authenticate your GitHub account with VS Code. This typically involves generating a Personal Access Token (PAT) from GitHub and adding it to VS Code.
  1. Workflow:
    1. Make changes to your files in VS Code.
    2. Commit those changes to the appropriate branch (e.g., `develop/staging` or `release`).
    3. 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
    
  • Initialize a new Git repository in your folder:
    git init
    
  • This command creates a hidden .git folder in your project directory, marking it as a Git repository.

2. Stage and Commit Your Files

  • Check the status of your repository to see untracked files:
    git status
    
  • Stage all your files for commit:
    git add .
    
  • Commit the files with a message:
    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
    
  • Verify the remote connection:
    git remote -v
    

4. Push Your Local Commits to GitHub

  • Now that your local repository is connected to the GitHub repository, push your changes:
    git push -u origin main
    
  • If your GitHub repository uses a different default branch (like master), replace main with the correct branch name.

5. Verify the Changes on GitHub

  • Go to your GitHub repository page and refresh it. You should see your .py and .html files listed there.

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.


  1. Deploying to the Staging Server:
    1. 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.
    2. Use tools like GitHub Actions, Jenkins, or a cron job to automate this process.
  1. Containerization and Production:
    1. Once everything is validated on the staging server, merge the changes into the `release` branch.
    2. 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.

flask_api_project_github_integration.txt · Last modified: 2024/10/17 21:42 by 127.0.0.1