mirror of
https://github.com/alexgo-io/redstone-cache-layer.git
synced 2026-01-12 16:53:15 +08:00
chore: lambda image building and pushing automated
This commit is contained in:
41
.github/workflows/deploy-lambda-to-ecr-public.yml
vendored
Normal file
41
.github/workflows/deploy-lambda-to-ecr-public.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# This workflow configuration is used
|
||||
# to automate building a public docker image of redstone-cache-layer-lambda
|
||||
# and publishing it to the AWS ECR Public
|
||||
|
||||
# Learn more: https://github.com/pahud/ecr-public-action
|
||||
|
||||
name: Deploy lambda image to Amazon ECR Public
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- push-docker-ecr-public
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
name: ECR public action
|
||||
steps:
|
||||
- name: Get repo name
|
||||
id: repoName
|
||||
run: echo "::set-output name=reponame::$(echo ${{github.repository}} | cut -d '/' -f 2)"
|
||||
- name: Get short SHA
|
||||
id: sha
|
||||
run: echo "::set-output name=sha7::$(echo ${GITHUB_SHA} | cut -c1-7)"
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- 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: us-east-1
|
||||
- name: Build and Push to ECR public
|
||||
id: build-and-push
|
||||
uses: pahud/ecr-public-action@8cd826db40befb59b0cd0b60b22a7ba72d06a7f7
|
||||
with:
|
||||
dockerfile: Dockerfile.lambda
|
||||
context: .
|
||||
create_repo: ecr_repo_name
|
||||
tags: |
|
||||
public.ecr.aws/y7v2w8b2/${{ steps.repoName.outputs.reponame }}-lambda:latest
|
||||
public.ecr.aws/y7v2w8b2/${{ steps.repoName.outputs.reponame }}-lambda:${{ steps.sha.outputs.sha7 }}
|
||||
@@ -17,7 +17,6 @@ RUN yarn build
|
||||
FROM public.ecr.aws/lambda/nodejs:16
|
||||
WORKDIR ${LAMBDA_TASK_ROOT}
|
||||
ENV MODE=PROD
|
||||
ENV ENABLE_AMPLITUDE_LOGGING=true
|
||||
COPY --from=builder /usr/app/ ./
|
||||
RUN cp -r ./dist/* ./
|
||||
CMD ["index.handler"]
|
||||
|
||||
@@ -9,26 +9,20 @@ import { enableAmplitudeLogging } from "../config";
|
||||
// Check the analytics dashboard using the link below
|
||||
// https://analytics.amplitude.com/limestone/dashboard/ttoropr
|
||||
|
||||
|
||||
export const logEvent = ({
|
||||
eventName,
|
||||
eventProps,
|
||||
ip,
|
||||
}) => {
|
||||
export const logEvent = ({ eventName, eventProps, ip }) => {
|
||||
if (enableAmplitudeLogging) {
|
||||
const client = Amplitude.init("4990f7285c58e8a009f7818b54fc01eb");
|
||||
|
||||
logger.info(
|
||||
`Logging event "${eventName}" in amplitude for ip: "${ip}". With props: `
|
||||
+ JSON.stringify(eventProps));
|
||||
client.logEvent({
|
||||
event_type: eventName,
|
||||
user_id: ip, // Currently we use ip address from request as a unique identifier
|
||||
// user_id: 'datamonster@gmail.com', // Maybe in future we will use some access tokens as user ids
|
||||
// location_lat: 37.77,
|
||||
// location_lng: -122.39,
|
||||
ip,
|
||||
event_properties: eventProps,
|
||||
});
|
||||
// const client = Amplitude.init("4990f7285c58e8a009f7818b54fc01eb");
|
||||
// logger.info(
|
||||
// `Logging event "${eventName}" in amplitude for ip: "${ip}". With props: `
|
||||
// + JSON.stringify(eventProps));
|
||||
// client.logEvent({
|
||||
// event_type: eventName,
|
||||
// user_id: ip, // Currently we use ip address from request as a unique identifier
|
||||
// // user_id: 'datamonster@gmail.com', // Maybe in future we will use some access tokens as user ids
|
||||
// // location_lat: 37.77,
|
||||
// // location_lng: -122.39,
|
||||
// ip,
|
||||
// event_properties: eventProps,
|
||||
// });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user