0
votes

I have a serverless nodejs project with aws lambda that I am trying to deploy. Before deploying i want to decrypt certain files and then trigger the actual deployment

This is the content of my main.yml file inside .github/workflows directory

name: Test

on: [deployment]

jobs:
  build:

    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@test
    - name: Decrypting files
      run: <decrypt commands here>
    - name: Actual Serverless Deployment
      run: sls deploy -s staging

It is not getting invoked if i do sls deploy. I am intrigued how github will know that its a deployment event if i trigger sls deploy command. Please help me in understanding when exactly the above deployment event will be triggered. What I am trying to achieve is to start a deployment command(ie., sls deploy -s staging or the like) and that invokes the above workflow -> (action1)decrypts files -> (action2)triggers actual deployment to lambda.

PS: The exact thing is working fine on git push, but i dont want it to deploy on every push to repo.

Please help me in understanding this. I am very new to github workflows.

1

1 Answers

0
votes

The deployment event occurs when a deployment is started, completed, etc. You can use Github Api to create a deployment: POST /repos/:owner/:repo/deployments (further details here: https://developer.github.com/v3/repos/deployments/#create-a-deployment)

Alternatively, you can use

on:
  push:
    branches:
    - master

to run your workflow only if something is merged to master.