Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy python function #73

Open
AntonOellerer opened this issue Jul 25, 2022 · 7 comments
Open

Deploy python function #73

AntonOellerer opened this issue Jul 25, 2022 · 7 comments

Comments

@AntonOellerer
Copy link

Hey,
I am currently unsucessfully trying to deploy a python serverless function with the github action.
My deploy.yml:

jobs:
  deploy:
    name: deploy
    runs-on: ubuntu-20.04
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version-file: '.python-version'
      - uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
      - run: npm ci
      - name: Deploy
        uses: serverless/[email protected]
        with:
          args: deploy --stage ${{ github.ref_name }} --verbose
        env:
          SERVERLESS_ACCESS_KEY: ${{ secrets.SERVERLESS_ACCESS_KEY }}

I also tried it with the approach suggested in the README.md, using

    - name: Install Plugin and Deploy
      uses: serverless/[email protected]
      with:
        args: -c "serverless plugin install --name <plugin-name> && serverless deploy"
        entrypoint: /bin/sh

but it did not work either. (If I am understanding the workflow correctly, npm ci should install the plugin, and the error message is coming from the plugin, so I think it should work either way)

The error I am getting is:

Running "serverless" from node_modules

Deploying <service> to stage staging (eu-central-1, "<provider>" provider)

Generated requirements from /github/workspace/requirements.txt in /github/workspace/.serverless/requirements.txt
Installing requirements from "/github/home/.cache/serverless-python-requirements/f8090527365eda7859729a5727d2f20270cee426c486e19c25ce91c8df2a8a66_x86_64_slspyc/requirements.txt"
Using download cache directory /github/home/.cache/serverless-python-requirements/downloadCacheslspyc

× Stack <service>-staging failed to deploy (0s)
Environment: linux, node 16.16.0, framework 3.21.0 (local) 3.21.0v (global), plugin 6.2.2, SDK 4.3.2
Credentials: Serverless Dashboard, "<provider>" provider (https://app.serverless.com/<provider>)
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Error: `python3.9 -m pip help install` Exited with code 1
    at ChildProcess.<anonymous> (/github/workspace/node_modules/child-process-ext/spawn.js:38:8)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.emit (node:domain:475:12)
    at maybeClose (node:internal/child_process:1092:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)

I think the error occurs here, but I can't quite grasp why the plugin should not be able to access python?

Do you know how to fix this?

@AntonOellerer
Copy link
Author

If I install serverless with npm and then run npm exec -c 'serverless deploy --stage ${{ github.ref_name }} --verbose' it works

@sergiors
Copy link

you need to use serverless/github-action@v3

@JoMingyu
Copy link

you need to use serverless/github-action@v3

this saved me

@walterholohan
Copy link

Thank you, anyone know why 3.1 does not work for python deployments?

@sergiors
Copy link

sergiors commented Feb 13, 2023

Thank you, anyone know why 3.1 does not work for python deployments?

The only reason that it could be is the node version, maybe python version

@jnicho02
Copy link

correct me if i'm wrong, but the 'with: args: ...serverless deploy' command will run inside serverless/github-action's Docker....3.1's Dockerfile is based on nikolaik/python-nodejs:python3.10-nodejs16-slim so when serverless tries to run python3.9 -m pip help install....then there won't be a python3.9, only a python3.10

and you can't use a python3.10 lambda profile as it doesn't exist yet https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

@advissor
Copy link

advissor commented Jun 7, 2023

Indeed, same happening for Python lambdas with v3.2 of this github action
@jnicho02 points in right direction
The Docker image, that is used and being built in the github actions uses Python 3.10 already for versions of Github actions above >3


 Step 1/11 : FROM nikolaik/python-nodejs:python3.10-nodejs18-slim
  python3.10-nodejs18-slim: Pulling from nikolaik/python-nodejs

Using serverless/github-action@v3 for Python 3.9 helped

      - name: Install Plugin and Deploy
        uses: serverless/github-action@v3
        with:
          args: -c "serverless plugin install --name serverless-python-requirements && serverless deploy"
          entrypoint: /bin/sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants