A simple Flask application that greets users with "hello my friends" and includes an automated CI/CD pipeline using GitHub Actions.
Status Badge
- Simple Flask web application
- Automated testing with pytest
- Continuous Integration and Continuous Deployment
- Docker containerization
- Automatic deployment to Docker Hub
.
├── app.py # Main Flask application
├── test_app.py # Pytest test suite
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── .github/
│ └── workflows/
│ └── ci-cd.yml # GitHub Actions workflow
└── README.md # This file
- Python 3.10+
- Docker (for containerization)
- GitHub account
- Docker Hub account
-
Clone the repository
git clone https://github.com/AnisEmad/Flask_hello.git cd Flask_hello -
Install dependencies
pip install -r requirements.txt
-
Run the application
python app.py
-
Run tests
pytest -v
The project uses GitHub Actions for automated testing and deployment. The pipeline is triggered on:
- Push to
mainbranch - Pull requests to
mainbranch
- Retrieves the latest code from the repository
- Installs Python 3.10
- Upgrades pip to the latest version
- Installs all required packages from
requirements.txt
- Executes pytest with verbose output
- Validates that the app returns "hello my friends"
- Sets up Docker Buildx for multi-platform builds
- Authenticates with Docker Hub using secrets
- Builds Docker image
- Pushes image to Docker Hub as
yansoon10/hello-app:latest - Only executes if all previous steps succeed
To enable Docker Hub deployment, add the following secrets to your GitHub repository:
- Go to your repository on GitHub
- Navigate to Settings → Secrets and variables → Actions
- Add the following secrets:
DOCKERHUB_USERNAME: Your Docker Hub usernameDOCKERHUB_TOKEN: Your Docker Hub access token
- Log in to Docker Hub
- Go to Account Settings → Security
- Click New Access Token
- Give it a description and create the token
- Copy the token and add it to GitHub secrets
Once the image is pushed to Docker Hub, you can run it anywhere:
docker pull yansoon10/hello-app:latest
docker run -p 5000:5000 yansoon10/hello-app:latestAccess the application at http://localhost:5000
The test suite validates that the Flask app returns the correct greeting message.
# Run all tests
pytest -v
# Run specific test file
pytest test_app.py -vThe complete workflow configuration can be found in .github/workflows/ci-cd.yml
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
The CI/CD pipeline will automatically run tests on your PR!
- Verify Docker Hub credentials in GitHub secrets
- Ensure Docker Hub token has write permissions
- Check if repository name
yansoon10/hello-appexists and you have access
- Ensure the Flask app returns exactly "hello my friends"
- Check Python version compatibility
- Verify all dependencies are in
requirements.txt
AnisEmad
- GitHub: @AnisEmad