-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (65 loc) · 2.67 KB
/
aws-lambda-manual-deploy.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
name: Manual deploy branch to dev-owned aws lambda
on:
[workflow_dispatch]
jobs:
lambda-build-zip-bucket-deploy:
name: deploy lambda function as zip package
runs-on: ubuntu-latest
steps:
- name: Get the codebase from the git repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install nodejs
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies (development)
run: npm ci
- name: Check code quality (ESLint)
run: npm run lint
- name: Run tests
run: npm run test
- name: Run build
run: npm run build
- name: Clean-up node_modules (extra-safe-measure :P)
run: rm -rf node_modules
- name: Install dependencies (production)
run: npm ci --production
- name: Get formatted date
id: date
run: echo "::set-output name=date::$(date +%Y%m%d-%H%M%S)"
- name: Get current package version
id: extract_version
uses: Saionaro/extract-package-version@v1.0.6
- name: Preparing package
id: prepare
env:
PKGVERSIONDATE: "v${{ steps.extract_version.outputs.version }}-${{ steps.date.outputs.date }}"
run: |
mkdir newpackage-${{ env.PKGVERSIONDATE }} \
&& cp -fr ./node_modules newpackage-${{ env.PKGVERSIONDATE }}/ \
&& cp -fr dist/* newpackage-${{ env.PKGVERSIONDATE }}/ \
&& cp -fr package.json newpackage-${{ env.PKGVERSIONDATE }}/ \
&& echo "PKGVERSIONDATE=${PKGVERSIONDATE}" >> $GITHUB_ENV
- name: Zipping package
run: |
cd newpackage-${{ env.PKGVERSIONDATE }} \
&& zip -r9q paymentconnector-${{ env.PKGVERSIONDATE }}.zip * \
&& ls -lha paymentconnector-${{ env.PKGVERSIONDATE }}.zip
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Pushing package to S3
run: |
aws s3 cp newpackage-${{ env.PKGVERSIONDATE }}/paymentconnector-${{ env.PKGVERSIONDATE }}.zip \
s3://commercetools-paymentconnector-lambda-releases/${{ github.actor }}/paymentconnector-${{ env.PKGVERSIONDATE }}.zip
- name: Updating lambda
run: |
aws lambda update-function-code \
--function-name=paymentconnector-${{ github.actor }} \
--s3-bucket=commercetools-paymentconnector-lambda-releases \
--s3-key=${{ github.actor }}/paymentconnector-${{ env.PKGVERSIONDATE }}.zip