Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 引入 serverless 和 sam,增加 AWS Lambda 部署目标
- Loading branch information
Showing
11 changed files
with
123 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm i -g yarn | ||
- run: yarn && yarn ci | ||
- run: yarn zip | ||
- uses: aws-actions/setup-sam@v2 | ||
- uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | ||
aws-region: us-east-1 | ||
- run: | | ||
cd sam | ||
sam build --use-container | ||
# Prevent prompts and failure when the stack is unchanged | ||
- run: | | ||
cd sam | ||
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,3 +138,6 @@ results3.txt | |
script.ps1 | ||
script2.ps1 | ||
script3.ps1 | ||
|
||
.env | ||
sam/*.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This file is auto generated by SAM CLI build command | ||
|
||
[function_build_definitions] | ||
|
||
[layer_build_definitions] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
EasySchoolBackendFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: ../../dist.zip | ||
Handler: dist/serverless/serverless.handler | ||
Runtime: nodejs18.x | ||
Timeout: 900 | ||
PackageType: Zip | ||
Events: | ||
ApiEvent: | ||
Type: Api | ||
Properties: | ||
Path: /{any+} | ||
Method: ANY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AWSTemplateFormatVersion: "2010-09-09" | ||
Transform: AWS::Serverless-2016-10-31 | ||
Resources: | ||
EasySchoolBackendFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: ./dist.zip | ||
Handler: dist/serverless/serverless.handler | ||
Runtime: nodejs18.x | ||
Timeout: 900 | ||
PackageType: Zip | ||
Events: | ||
ApiEvent: | ||
Type: Api | ||
Properties: | ||
Path: /{any+} | ||
Method: ANY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const app = require('./app'); | ||
|
||
app.listen(8080); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const ServerlessHttp = require("serverless-http"); | ||
const app = require("./app"); | ||
|
||
module.exports.handler = ServerlessHttp(app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters