twilio-labs / serverless-toolkit

CLI tool to develop, debug and deploy Twilio Functions

Home Page:https://www.twilio.com/docs/labs/serverless-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: Process completed with exit code 1.

opened this issue · comments

Heyo, I continue to run into this error while within the Github server, but not in my terminal.

The issue is something with this line 35 in the Main.Yaml " run: npm install twilio-cli -g && twilio plugins:install @twilio-labs/plugin-serverless && twilio serverless:deploy --service-name=example-deployed-with-github-actions --environment=dev --force"

Any ideas of how to fix this error
Screen Shot 2021-09-28 at 3 29 30 PM
Screen Shot 2021-09-28 at 3 25 36 PM

Hey, I just forked your repo and got it to work first time. So not sure what's wrong with your repo.

Can you confirm you have added your Account SID and an API Key and API Secret correctly to your repo secrets? I can see they appear in the output as in the env as the output contains:

  env:
    TWILIO_ACCOUNT_SID: ***	
    TWILIO_API_KEY: ***
    TWILIO_API_SECRET: ***

Did you follow these instructions to fetch the credentials?

Are you able to add the debug flag -l debug to the command and see if that gives any more information?

Hey thanks, that was helpful. I did add those but I must have done something wrong. Thanks for forking and checking it. I've got a follow up question. So now that I've done this. How would I go about having my current java code in twilio, brought so that collaborators on github can make changes for my approval, and then once approved go straight to the code in twilio?

I'm not sure I understand exactly what you're asking here. The Action in that repo will now deploy the Twilio Functions and Assets in the repo when changes are pushed to the main branch. That sounds like what you are describing. Am I missing something?

Thanks Phil, so my end goal is to have a code (that I currently have built in Twilio) connected to github so that collaborators can make changes and submit those in github. Once approved in github, I want those approved changes to be made automatically to the code housed in twilio. Does that clarify/seem possible?

Aside from using example code, that is what your repo is doing. Every time you push new code to the main branch it will deploy the code to Twilio. Functions.

So you'll need to get your code from your existing Functions, add them to the repo (or create a new one based on it).

Is there something about what you've set up here that you don't think does what you want?

So, it's probably best to get your application running successfully on your local machine using the Serverless Toolkit first (the Serverless Toolkit is what is being used by the GitHub Action to perform the deploys).

Install the Twilio CLI following the instructions here: https://www.twilio.com/docs/twilio-cli/quickstart

Once installed, login to your Twilio account by running the twilio login command.

Then install the Serverless Toolkit: twilio plugins:install @twilio-labs/plugin-serverless

In your local project, you should now be able to run twilio serverless:start. This will start up your functions, but they will have the problems you've described.

To fix the dependencies you can npm install the dependency into the application. This adds it to your package.json file and the Serverless Toolkit will then install it in your Twilio Functions Service when it is deployed.

For the environment variables, we may need to take a different path. Locally you can create a .env file and add the environment variables to it in the form VARIABLE_NAME=VALUE. But you don't want to include that .env file in your source control because it contains secrets. I've not done this next step before myself, so bear with me if it doesn't work first time.

So when deploying from GitHub Actions you'll want to add the environment variable to the secrets alongside your Account Sid, API Key and API Secret. Once you've done that you can use the twilio serverless:env:set command to set the environment variable once your application has completed it's deployment. Add this command to the end of your deploy command:

twilio serverless:env:set --key=AIRTABLE_BASE_KEY --value=$AIRTABLE_BASE_KEY --environment=dev

You can add as many commands as you need at the end of your deploy command. You can actually run multiple commands in an action without having to chain && by using the pipeline operator. So your run command should look like this (based on what's in your repo right now):

        env:
          TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
          TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }}
          TWILIO_API_SECRET: ${{secrets.TWILIO_API_SECRET}}
          AIRTABLE_BASE_KEY: ${{secrets.AIRTABLE_BASE_KEY}}
          AIRTABLE_API_KEY: ${{secrets.AIRTABLE_API_KEY}}
        run: |
          npm install twilio-cli -g
          twilio plugins:install @twilio-labs/plugin-serverless
          twilio serverless:deploy --service-name=example-deployed-with-github-actions --environment=dev --force
          twilio serverless:env:set --key=AIRTABLE_BASE_KEY --value=$AIRTABLE_BASE_KEY --environment=dev
          twilio serverless:env:set --key=AIRTABLE_API_KEY --value=$AIRTABLE_API_KEY --environment=dev

Now, once you push to your repo, the Serverless Toolkit will be able to install the dependencies from your package.json and add your environment variables from your GitHub repo secrets. Let me know how you get on with that.

The easiest way I know to delete a service is to use the Twilio CLI and run:

twilio api:serverless:v1:services:remove --sid YOUR_SERVICE_SID