70 lines
1.6 KiB
YAML
70 lines
1.6 KiB
YAML
name: AWS Lambda CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
pull_request:
|
|
branches: [ master ]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Lambda Layer
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16.x
|
|
|
|
- name: Install Packages
|
|
run: npm install
|
|
|
|
- name: Create Lambda Layer
|
|
run: make chromium.zip
|
|
|
|
- name: Upload Layer Artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: chromium
|
|
path: chromium.zip
|
|
|
|
execute:
|
|
name: Lambda (Node ${{ matrix.version }}.x)
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
event:
|
|
- example.com
|
|
version:
|
|
- 14
|
|
- 16
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Python
|
|
uses: actions/setup-python@v3
|
|
with:
|
|
python-version: '3.x'
|
|
|
|
- name: Setup AWS SAM CLI
|
|
uses: aws-actions/setup-sam@v2
|
|
|
|
- name: Download Layer Artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: chromium
|
|
|
|
- name: Provision Layer
|
|
run: unzip chromium.zip -d _/amazon/code
|
|
|
|
- name: Install test dependencies
|
|
run: npm install --prefix _/amazon/handlers puppeteer-core --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false
|
|
|
|
- name: Invoke Lambda on SAM
|
|
run: sam local invoke --template _/amazon/template.yml --event _/amazon/events/${{ matrix.event }}.json node${{ matrix.version }} 2>&1 | (grep 'Error' && exit 1 || exit 0)
|