Skip to content

Deploy python function #73

@AntonOellerer

Description

@AntonOellerer

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/github-action@v3.1
        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/github-action@v3.1
      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?

Activity

AntonOellerer

AntonOellerer commented on Jul 25, 2022

@AntonOellerer
Author

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

sergiors

sergiors commented on Sep 29, 2022

@sergiors

you need to use serverless/github-action@v3

JoMingyu

JoMingyu commented on Oct 27, 2022

@JoMingyu

you need to use serverless/github-action@v3

this saved me

walterholohan

walterholohan commented on Feb 13, 2023

@walterholohan

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

sergiors

sergiors commented on Feb 13, 2023

@sergiors

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

jnicho02 commented on Mar 15, 2023

@jnicho02

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

advissor commented on Jun 7, 2023

@advissor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Deploy python function · Issue #73 · serverless/github-action