-
Notifications
You must be signed in to change notification settings - Fork 32
73 lines (63 loc) · 2.49 KB
/
upload_lambda_from_comment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# GitHub workflow file
name: Deploy on demand Online DevOps Dojo coach lambda
on:
issue_comment:
types: [created, edited]
jobs:
reaction_on_comment:
runs-on: ubuntu-20.04
if: startsWith(github.event.comment.body, '/deploy')
steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ github.event.comment.id }}
body: '**Go!**'
reaction-type: rocket
deploy_on_comment:
runs-on: ubuntu-20.04 # includes Node.js 12, same version as for AWS Lambda
needs: reaction_on_comment
timeout-minutes: 10
steps:
- name: "Triggered by ${{ github.actor }}"
run: echo Workflow triggered by $GITHUB_ACTOR
- name: Copy the repository
uses: actions/checkout@v2
# Node 12 included in LTS ubuntu-20.04 matches the version used for AWS Lambda
# (https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu2004-README.md)
# hence comment the upgrade code for now
# - name: Check Node 12
# uses: actions/setup-node@v1.4.2
# with:
# node-version: 12
# not supported yet for issue_comment event
# - name: Cache node modules
# uses: actions/cache@v2
# env:
# cache-name: cache-node-modules
# with:
# path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
# Install nodejs packages listed in package-lock.json.
- name: Install node modules
run: npm ci --only=prod --no-fund
# run "serverless deploy --verbose" in a docker container and run the config file serverless.yml
- name: Deploy lambda
uses: serverless/github-action@v2.1.0
env: # all mandatory
# AWS
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_STAGE: ${{ secrets.AWS_STAGE }}
# GITHUB APP
APP_ID: ${{ secrets.APP_ID }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
with:
args: deploy --verbose