Skip to content

Add examples for using Serverless Plugins #28

Description

@matthewpoer

Sharing an example of using this Action with one or more SLS Serverless plugins. Would be nice to add some notes around this to the README.md. The key is to set both args and entrypoint on the step.

Similar tactic is used in #26 to capture resources.Outputs data.

name: Deploy
on:
  push:
    branches:
      - master
jobs:
  deploy:
    name: Deployment
    runs-on: ubuntu-latest
    strategy:
      matrix:
        stages:
          - stage: 'dev'
            AWS_SECRET_ACCESS_KEY: 'AWS_SECRET_ACCESS_KEY_DEV'
            AWS_ACCESS_KEY_ID: 'AWS_ACCESS_KEY_ID_DEV'
          - stage: 'prod'
            AWS_SECRET_ACCESS_KEY: 'AWS_SECRET_ACCESS_KEY_PROD'
            AWS_ACCESS_KEY_ID: 'AWS_ACCESS_KEY_ID_PROD'
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Install VPC Plugin and Deploy
      uses: serverless/github-action@v1.53.0
      with:
        args: -c "serverless plugin install --name serverless-vpc-discovery && serverless deploy --stage=${{ matrix.stages.stage }} --verbose"
        entrypoint: /bin/bash
      env:
        AWS_ACCESS_KEY_ID: ${{ secrets[matrix.stages.AWS_ACCESS_KEY_ID] }}
        AWS_SECRET_ACCESS_KEY: ${{ secrets[matrix.stages.AWS_SECRET_ACCESS_KEY] }}
        SLS_DEBUG: 1

Activity

  1. benjefferies commented on May 3, 2020

    @benjefferies

    I was just about to start figuring this out but you've saved me some time. Thanks for the issue/documentation @matthewpoer

  2. matthewpoer commented on Feb 22, 2021

    @matthewpoer
    Author

    Update for all those who find this the hard way: serverless plugin install ... will find and install the latest version of a plugin. You can tag specific versions, but I found this easier:

        - name: Install SLS Plugins and Deploy
          uses: serverless/github-action@v1.53.0
          with:
            args: -c "npm install --also=dev && npm list -g && npm list && serverless deploy --stage=${{ matrix.stages.stage }} --verbose"
            entrypoint: /bin/bash

    The extra npm list bits are nice to check versions :D

  3. porthunt commented on Aug 24, 2021

    @porthunt

    For anyone getting this error:

    docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.
    time="2021-08-24T14:37:43Z" level=error msg="error waiting for container: context canceled"
    

    Change the entrypoint to /bin/sh. It affects >2.18.0 (therefore master too).

    More info on #52

  4. Ddevon commented on Aug 23, 2022

    @Ddevon

    does this not relevant if the plugins were installed with npm?

  5. added 2 commits that reference this issue on May 17, 2024
    38e5d57
    776ee70
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