GithubHelp home page GithubHelp logo

goodsmileduck / yandex-serverless-action Goto Github PK

View Code? Open in Web Editor NEW
42.0 42.0 6.0 25.38 MB

Github Action for deploying code to existed Serverless function in Yandex cloud

Python 2.36% TypeScript 97.64%
github github-action serverless yandex-function

yandex-serverless-action's People

Contributors

batformat avatar dependabot[bot] avatar goodsmileduck avatar konclave avatar scrabyq avatar sergeyzwezdin avatar vermilion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

yandex-serverless-action's Issues

[Feature Request] возможность не "exclude файлы из сборки", а наоборот "include только нужное"

Пишу этот issue в 3 часа ночи, поэтому pr не сделал. Я предлагаю 2 простых изменения в коде, которые позволят сделать загружаемые на сервера яндекса архивы с функциями более чистыми

  1. Добавить условие на строку 53, чтобы можно было загружать архивы напрямую
// Было
const fileContents = await zipDirectory(inputs);

// Стало
import { promises as fs } from "fs"

const fileContents = await (
  inputs.source.endsWith('.zip') 
    ? fs.readFile(inputs.source) 
    : zipDirectory(inputs)
)
  1. Выбор только нужных файлов (строка 184-190)
await archive
            // TODO: Добавить files в inputs и actions.yml
            .glob(inputs.files  ?? "**", {
                cwd: inputs.source,
                dot: true,
                ignore: parseIgnoreGlobPatterns(inputs.sourceIgnore)
            })
            .finalize();

Удачи в развитии экшена

Feature request: add service account option

The requested feature: add parameter service-account-id to the action.

Generally, it is expected that all the parameters described by yc serverless function version create --help can be passed to the action.

Why it is important: when a service account is added to a function, it can receive IAM-tokens on each call and use them to call other APIs of Yandex.Cloud (e.g. translate API). This is very convenient e.g. for Alice skills using these APIs.

Feature request: Add ignore pattern

It would be very nice to have ability to add ignore filter for files that should be packed into the archive. For now, we need to explicitly copy the result to another folder that could be time-consuming.

Error if environment not passed

In configuration section indicated that the parameter environment not required. But if it is not passed, then there will be an error:

##[error]3 INVALID_ARGUMENT: Validation failed:
  - environment[]: Field does not match the pattern /[a-zA-Z][a-zA-Z0-9_]*/

Error INVALID_ARGUMENT: Исходный архив не является валидным ZIP архивом

Не получается задеплоить функцию на go

Ошибка из YC

INVALID_ARGUMENT: Исходный архив не является валидным ZIP архивом

Yml файл

name: Push and Deploy Serverless function
on: push

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: goodsmileduck/yandex-serverless-action@v2
        with:
          token: ${{ secrets.TOKEN }}
          function_id: "***"
          runtime: "golang121"
          entrypoint: "index.Handler"
          exclude: "main.go"
          environment: YDB_METADATA_CREDENTIALS=1

Файл логов github action

logs_10.zip

ERROR: zip archive content exceeds the maximum size 3.5 MB, use object storage to upload the content

aws --endpoint-url=https://storage.yandexcloud.net s3 cp ${GITHUB_SHA}.zip s3://${BUCKET}/${FUNCTION_NAME}/${GITHUB_SHA}.zip

Hi!

Function version uploaded into the cloud storage is being afterwards "created" with --source-path, which is wrong. Instead it should be created with --package-bucket-name and --package-object-name.

Would you be able to fix it? For my part, I could offer to make a pull request.

Thank you for such a great tool!

Deployment doesn't work

Trying to setup YF deployment. Here is how my workflow definition looks:

CleanShot 2019-11-25 at 05 23 52@2x

But when I run it, I'm getting an error:

CleanShot 2019-11-25 at 05 24 47@2x

Fail during initialization

I use the latest version from master:

    - name: Deploy YF
      uses: goodsmileduck/yandex-serverless-action@0cd492301916f9cbcbaeb68393f0a658a741ec44
      env:

Build started failing today:

 ---> Using cache
 ---> 0917ee5e5cb1
Step 3/12 : RUN go get -u -v github.com/a8m/envsubst/cmd/envsubst
 ---> Using cache
 ---> 400461e63b09
Step 4/12 : FROM plugins/base:linux-amd64
 ---> 8c692aac9d91
Step 5/12 : LABEL maintainer="Serebrennikov Stanislav <[email protected]>"   org.label-schema.name="Yandex Cloud function deploy"   org.label-schema.vendor="Serebrennikov Stanislav"   org.label-schema.schema-version="1.0"
 ---> Using cache
 ---> 8ce40c9424a0
Step 6/12 : ENV ZONE=ru-central1-a   MEMORY=128m   TIMEOUT=5s
 ---> Using cache
 ---> 3dc188637f23
Step 7/12 : COPY --from=builder /go/bin/envsubst /bin/envsubst
 ---> Using cache
 ---> 524dfdb0ae28
Step 8/12 : RUN apk add curl bash python py-pip zip &&   curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash &&   pip install awscli &&   ln -s /root/yandex-cloud/bin/yc /bin/yc
 ---> Running in b054555413e5
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  python (missing):
    required by: world[python]
The command '/bin/sh -c apk add curl bash python py-pip zip &&   curl https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash &&   pip install awscli &&   ln -s /root/yandex-cloud/bin/yc /bin/yc' returned a non-zero code: 1
##[error]Docker build failed with exit code 1

More info about exclude

Please, add more information about exclude patterns in README. I found out from code, that several patterns could be written comma separated. Also it would be nice, if you say something about pattern syntax - Is it regex or something simplier?

[BUG] action v2 has no effect on the cloud

Hi there!
I appreciate your work; it helps me run a lot of lambdas and works like a charm!

However, yandex-serverless-action@v2 doesn't seem to work.

This is my action:

      - uses: goodsmileduck/yandex-serverless-action@v2
        with:
          token: ${{ secrets.YC_TOKEN }}
          function_id: ${{ secrets.YC_FUNCTION_ID }}
          service_account: ${{ secrets.YC_SERVICE_ACCOUNT }}
          bucket: ${{ secrets.YC_BUCKET }}
          accessKeyId: ${{ secrets.ACCESS_KEY_ID }}
          secretAccessKey: ${{ secrets.SECRET_ACCESS_KEY }}
          runtime: 'python311'
          memory: '1024'
          execution_timeout: '15'
          entrypoint: 'ycloud.handler'
          environment: VAR1=${{ secrets.VAR1 }},VAR2=${{ secrets.VAR2 }},VAR3=${{ secrets.VAR3 }}
          source: 'app'

This is success log of execution (in 2 seconds):

Run goodsmileduck/yandex-serverless-action@v2
  with:
    token: ***
    function_id: ***
    service_account: ***
    bucket: ***
    accessKeyId: ***
    secretAccessKey: ***
    runtime: python311
    memory: 1024
    execution_timeout: 15
    entrypoint: ycloud.handler
    environment: VAR1=***,VAR2=***,VAR3=***
    source: app
Function inputs set
::group::ZipDirectory
ZipDirectory
  Archive initialize
  Source ignore pattern: "[]"

When I looked at the developer console, I saw no new version of lambda deployed. I didn't see any new archive in Object Storage either.

But if I change v2 to v1 - it works as expected. Here is the success log (31 seconds):

Warning: Unexpected input(s) 'accessKeyId', 'secretAccessKey', valid inputs are ['description', 'token', 'function_id', 'bucket', 'runtime', 'entrypoint', 'source', 'exclude', 'memory', 'environment', 'execution_timeout', 'service_account']
Run goodsmileduck/yandex-serverless-action@v1
Function inputs set
::group::ZipDirectory
ZipDirectory
Buffer size: 59809425b
Upload to bucket: "***/***/***.zip"
::group::Get function by ID: "***"
Get function by ID: "***"
::group::Create function version
Create function version
::set-output name=time::09:54:35 GMT+0000 (Coordinated Universal Time)
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

I know that it's not the best bug description, but that's all I have. It's not a blocker for me as well - I continue using v1 and it's cover 100% of my requirements.

The action doesn't cleanup after deployment

If I deploy more than one YF in a single GH workflow, files from the first deployed function appear in second function. Probably need to clean up SOURCE_DIR before zipping/deployment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.