appleboy / lambda-action

GitHub Action for Deploying Lambda code to an existing function
https://github.com/marketplace/actions/aws-lambda-deploy
MIT License
394 stars 58 forks source link

Does this Action update the python environment from requirements.txt? #40

Closed jgwinner closed 1 year ago

jgwinner commented 3 years ago

Hello:

The best of the Lambda's updaters, the only one I've seen that request python version.

A question though - will this install a virtual environment from requirements.txt and upload that inside the .zip file?

It wasn't clear from the docs.

jgwinner commented 3 years ago

Ah, after running it, it looks like although the key python3.6 can be loaded, it's really just uploading whatever .zip file is in the artifact, not making it, itself.

w0rldart commented 3 years ago

@jgwinner what are you using then to process the requirements?

jgwinner commented 3 years ago

I basically took a shell script we used before to do the deploy, and hacked it up to work inside the runner.

This was more work than it sounds like. It took me a while to find out the location of "site packages".

          run: python -m venv venv && source venv/bin/activate &&
              pip3 install -r requirements.txt

        # activate the venv
        - name: Activate venv 
          run: . venv/bin/activate 
          # TODO would run tests here; 
          ## create zipfile

        # add our venv / dependencies to the zip
        - name: Add Dependencies to Zip file
          run: |
            mkdir -v to_deploy
            find . -name "*.py" -maxdepth 1 -exec cp {} to_deploy \;
            ls -l to_deploy
            cp -r ./venv/lib/python3.8/site-packages/* to_deploy

I don't know if this is the 'right' way, but it worked.

    == John ==
jgwinner commented 3 years ago

Oh - we also updated to 3.8 instead of 3.6 (whew)