diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml new file mode 100644 index 0000000..626c2f4 --- /dev/null +++ b/.github/workflows/lambda.yml @@ -0,0 +1,39 @@ +name: Lambda +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Checkout the pull request branch + - name: Checkout code + uses: actions/checkout@v2 + + # Rebuild README + - name: Prepare + shell: bash + run: | + set -ex + make init + make terraform/install + make terraform/get-plugins + make terraform/get-modules + make terraform/lint + make terraform/validate + + - name: Build + run: make build + + - name: Deploy + run: aws s3 cp --acl public-read artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Test Download from CDN + run: curl -fsSL -o /dev/null https://artifacts.cloudposse.com/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip diff --git a/Makefile b/Makefile index e458558..0f5ff64 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ lint: $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate define docker -docker run -it -v $(PWD)/$(LAMBDA_DIR)/:/code -w /code $(DEPS_CONTAINER) /bin/sh -c '$(1)' +docker run -i -v $(PWD)/$(LAMBDA_DIR)/:/code -w /code $(DEPS_CONTAINER) /bin/sh -c '$(1)' endef ## Install dependencies @@ -28,4 +28,5 @@ dependencies: build: dependencies @echo "==> Building Lambda function zip..." @mkdir -p artifacts - @cd $(LAMBDA_DIR) && zip -r ../artifacts/lambda.zip * && cd ../ + @cd $(LAMBDA_DIR) && zip -r ../artifacts/lambda.zip * + @ls -l artifacts/lambda.zip diff --git a/README.md b/README.md index f285c4f..f7f85de 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ # terraform-aws-lambda-elasticsearch-cleanup - [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905) [![GitHub Action Build Status](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/workflows/Lambda/badge.svg?branch=master)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/actions?query=workflow%3ALambda) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) Terraform module to provision a scheduled Lambda function which will diff --git a/README.yaml b/README.yaml index 2e4bb7e..c66dbb8 100644 --- a/README.yaml +++ b/README.yaml @@ -21,6 +21,9 @@ badges: - name: "Codefresh Build Status" image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1" url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905" + - name: "GitHub Action Build Status" + image: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/workflows/Lambda/badge.svg?branch=master" + url: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/actions?query=workflow%3ALambda" - name: "Latest Release" image: "https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg" url: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest"