This project demonstrates a simple Flask application. It highlights the integration of GitHub Actions for CI/CD with two main steps: testing the application using pytest
and building/publishing a Docker image.
The GithubActionsTutorialProject provides an end-to-end demonstration of setting up CI/CD pipelines using GitHub Actions for a Python Flask app. The project includes automated testing with pytest
and Dockerization to facilitate continuous deployment.
- Simple Flask app.
- Automated testing using
pytest
. - CI/CD pipeline configuration with GitHub Actions to automate build, test, and deploy processes.
- Dockerized application for easy deployment.
- Python 3.7 or higher
- Docker
- GitHub account with access to GitHub Actions
- Clone the repository:
git clone https://github.com/username/GithubActionsTutorialProject.git
cd GithubActionsTutorialProject
- Install the required packages:
pip install -r requirements.txt
- Run the Flask application:
flask run
- Run tests:
pytest
This project includes a GitHub Actions workflow with two primary jobs:
This job performs the following:
- Checks out the code.
- Sets up the Python environment.
- Installs the dependencies from
requirements.txt
. - Runs the tests using
pytest
to ensure code functionality.
This job is triggered after a successful test and performs the following:
- Checks out the code.
- Sets up Docker Buildx.
- Logs into DockerHub.
- Builds and pushes the Docker image to DockerHub.
To build and run the Docker container locally:
- Build the Docker image:
docker build -t flask-app .
- Run the Docker container:
docker run -p 5000:5000 flask-app
- Fork the project.
- Create a feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a pull request.