'GitHub Actions: Zip python project with dependencies

I'm trying to connect my GitHub repository with an AWS lambda funciton. I was trying one youtube video and was going well. Basically, I need to create a GitHub Action that archives all my dependencies and code. I have the following code:

name: Build and deploy Python app to AWS Web App - foss-api-testing
on:
  # Trigger the workflow on push
  push:
    branches:
      # Push events on main branch
      - main

# The Job defines a series of steps that execute on the same runner.
jobs:

  CI:
    # Define the runner used in the workflow
    runs-on: ubuntu-latest
    steps:
      # Check out repo so our workflow can access it
      - uses: actions/checkout@v2

      # Step-1 Setup Python
      - name: Set up Python
        # This action sets up a Python environment for use in actions
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
          # optional: architecture: x64 x64 or x86. Defaults to x64 if not specified

      # Step-2 Install Python Virtual ENV
      - name: Install Python Virtual ENV
        run: pip3 install virtualenv

      # Step-3 Setup Virtual ENV
      # https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
      - name:  Virtual ENV
        uses: actions/cache@v2
        id: cache-venv # name for referring later
        with:
          path: venv # what we cache: the Virtual ENV
          # The cache key depends on requirements.txt
          key: ${{ runner.os }}-venv-${{ hashFiles('**/requirements*.txt') }}
          restore-keys: |
            ${{ runner.os }}-venv-

      # Step-4 Build a Virtual ENV, but only if it doesn't already exist
      - name: Activate Virtual ENV
        run: python -m venv venv && source venv/bin/activate && pip3 install -r requirements.txt
        if: steps.cache-venv.outputs.cache-hit != 'true'

      - name: Create archive of dependencies
        run: |
          cd ./venv/lib/python3.9/site-packages
          zip -r9 ../../../../api.zip .

      - name: Add API files to Zip file
        run: cd ./ && zip -g ../api.zip -r .

      - name: Upload zip file artifact
        uses: actions/upload-artifact@v2
        with:
          name: api
          path: api.zip

My project structure is:

C:.
|   app.py
|   requirements.txt
|   
+---.github
|   \---workflows
|           main_foss-api-testing.yml
|           
|           
+---models
|   |   Glue_Type.py
|   |   Uv_Active.py
|   |   
|   +---ml
|   |   |   classifier.py
|   |   |   
|   |   +---Glue_Type
|   |   |       ld_model_v1.joblib
|   |   |       
|   |   +---Uv_Active
|   |   |       knn_model_v1.joblib
|   |   |       
|   |   \---__pycache__
|   |           classifier.cpython-39.pyc
|   |           
|   \---__pycache__
|           Glue_Type.cpython-39.pyc
|           Uv_Active.cpython-39.pyc
|           
\---venv

My problem is in this line. I need to add into the zip all the folders inside my project. However, when I type "cd ./" no files are imported.

 - name: Add API files to Zip file
    run: cd ./ && zip -g ../api.zip -r .


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source