Merge pull request #23 from mriusero/branch_3 #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Github-Docker Hub pipeline - GenAI Quantum Insights | |
env: | |
DOCKER_USER: ${{secrets.DOCKER_USER}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
REPO_NAME: ${{secrets.REPO_NAME}} | |
# Event Triggers: | |
# The pipeline is triggered whenever there is a push to the main branch. | |
# It is also triggered whenever there is a pull request to the main branch. | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
ci_pipeline: | |
runs-on: ubuntu-latest # The job runs on the ubuntu-latest operating system | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
fetch-depth: 0 | |
# The first step uses the actions/checkout@v1 action to clone the repository. | |
# The fetch-depth: 0 parameter ensures that the complete commit history is fetched. | |
- name: Set up Python 3.10 # Sets up Python 3.9 using the setup-python action. | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
- name: Install system dependencies # Installs the same system dependencies as in the Dockerfile. | |
run: | | |
sudo apt-get update && sudo apt-get install -y curl build-essential libssl-dev libffi-dev python3-dev | |
- name: Install Poetry # Installs Poetry and adds it to PATH to ensure it's available in subsequent steps. | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
echo "export PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV | |
- name: Configure Poetry to create virtualenvs # Configures Poetry to create virtual environments. | |
run: | | |
poetry config virtualenvs.create true | |
- name: Install dependencies # Installs project dependencies using Poetry with the --no-dev flag, as in the Dockerfile. | |
run: | | |
poetry install --no-dev | |
- name: Format code with Black # Formats the app.py file using the black code formatter through Poetry. | |
run: | | |
poetry run black app.py | |
- name: Lint code with Pylint # Performs linting on the app.py file using pylint through Poetry. The --disable=R,C flag disables specific pylint checks. | |
run: | | |
poetry run pylint --disable=R,C app.py | |
#- name: Run tests with Pytest # Runs tests using pytest through Poetry. | |
# run: | | |
# poetry run pytest -vv | |
- name: Health Check # Performs a health check similar to the Dockerfile's HEALTHCHECK. | |
run: | | |
mkdir -p ~/.streamlit/ && \ | |
echo "[general]" > ~/.streamlit/credentials.toml && \ | |
echo "email = \"\"" >> ~/.streamlit/credentials.toml | |
nohup poetry run streamlit run app.py --server.port 8501 & | |
sleep 10 | |
curl --fail http://localhost:8501/_stcore/health || exit 1 | |
shell: bash | |
cd_pipeline: | |
runs-on: ubuntu-latest | |
needs: [ci_pipeline] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: docker login | |
run: | # log into docker hub account | |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | |
- name: Get current date # get the date of the build | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d--%M-%S')" | |
- name: Build the Docker image # push The image to the docker hub | |
run: docker build . --file Dockerfile --tag $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} | |
- name: Docker Push | |
run: docker push $DOCKER_USER/$REPO_NAME:${{ steps.date.outputs.date }} |