-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (115 loc) · 3.35 KB
/
deploy.yml
File metadata and controls
138 lines (115 loc) · 3.35 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
name: Build and Release Lambda
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
env:
FUNCTION_NAME: lambda-basic
RUNTIME: nodejs20.x
HANDLER: index.handler
permissions:
contents: write
packages: write
jobs:
validate:
name: Validate and Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'src/package-lock.json'
- name: Configure npm
run: |
npm config set registry https://registry.npmjs.org/
npm config set fetch-retries 3
npm config set fetch-retry-mintimeout 5000
npm config set fetch-retry-maxtimeout 60000
- name: Install dependencies
run: |
cd src
npm install --no-audit --no-fund
- name: Run tests
run: |
cd src
npm test
- name: Build function
run: |
cd src
npm run build
- name: Package function
run: |
cd src
npm run package
- name: Verify package
run: |
if [ ! -f "src/function.zip" ]; then
echo "❌ Package file not created"
exit 1
fi
echo "✅ Package file created successfully"
ls -la src/function.zip
release:
name: Create Release
runs-on: ubuntu-latest
needs: validate
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'src/package-lock.json'
- name: Configure npm
run: |
npm config set registry https://registry.npmjs.org/
npm config set fetch-retries 3
npm config set fetch-retry-mintimeout 5000
npm config set fetch-retry-maxtimeout 60000
- name: Install dependencies
run: |
cd src
npm install --no-audit --no-fund
- name: Build function
run: |
cd src
npm run build
- name: Package function
run: |
cd src
npm run package
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: src/function.zip
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
body: |
## Lambda Function Release
**Function:** ${{ env.FUNCTION_NAME }}
**Runtime:** ${{ env.RUNTIME }}
**Handler:** ${{ env.HANDLER }}
### Installation
1. Download the `function.zip` file
2. Upload to AWS Lambda console or use AWS CLI
3. Set handler to: `index.handler`
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag Latest
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f latest
git push origin latest --force