diff --git a/.github/workflows/lambda-deploy.yaml b/.github/workflows/lambda-deploy.yaml new file mode 100644 index 0000000..d799d4b --- /dev/null +++ b/.github/workflows/lambda-deploy.yaml @@ -0,0 +1,39 @@ +name: Lambda Deploy + +on: [push] +jobs: + get-filenames: + runs-on: ubuntu-latest + outputs: + lambdaArray: ${{ steps.getLambdas.outputs.lambdas }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Get functions filenames + id: getLambdas + run: | + lambdas=$(tree -d -L 1 -J . | jq -j -c '.[0].contents | map(.name)') + echo ::set-output name=lambdas::${lambdas} + update-code: + needs: get-filenames + strategy: + matrix: + lambda: ${{ fromJSON(needs.get-filenames.outputs.lambdaArray) }} + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Get 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: us-east-2 + - name: Zip Lambda functions + run: zip -j ${{matrix.lambda}}.zip ./${{matrix.lambda}}/index.js + - name: Update Lambdas code + run: aws lambda update-function-code --function-name=${{matrix.lambda}}${{inputs.environment}} --zip-file=fileb://${{matrix.lambda}}.zip \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index c776897..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: deploy to lambda -on: [push] -jobs: - deploy_source: - name: build and deploy lambda - strategy: - matrix: - node-version: [20.x] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 - with: - node-version: ${{ matrix.node-version }} - - name: npm install and build - run: | - npm i - npm run build --if-present - env: - CI: true - - name: zip - uses: montudor/action-zip@v0.1.0 - with: - args: zip -qq -r ./bundle.zip ./ - - name: default deploy - uses: appleboy/lambda-action@master - with: - aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws_region: ap-southeast-2 - function_name: getText - zip_file: bundle.zip diff --git a/index.js b/getText/index.js similarity index 100% rename from index.js rename to getText/index.js