-
Push to BitBucket triggers API Gateway which triggers AWS Lambda
-
AWS Lambda clones the BitBucket repository onto the AWS Lambda then pushes the latest code to GitHub
-
Once the code hits GitHub it triggers the Serverless Framework Pro CI/CD which will deploy the updates
- nodejs12.x runtime
nodegit
is a native npm module, we can't package from MacOS and directly upload. Meaning we need to build a Docker container and deploy from there. Below are the steps.
-
Create a BitBucket private repo & create a GitHub private repo
-
Create an app password with BitBucket & create a Github personal access token
-
Setup Serverless Framework Pro org, app, profile with AWS IAM role deployment, and profile params matching environment variables listed in
serverless.yml
-
Create a Serverless Framework Pro personal access key
-
Install Docker + Start Docker + Run
docker build -t git-mirror-lambda .
to build deployment container locally -
Run
docker run -it git-mirror-lambda /bin/bash
to get inside the container -
Run
cd /app
to get into right folder -
Run
export SERVERLESS_ACCESS_KEY=XXXXXXXXX
swapping in your Serverless Framework Personal access key -
Run
sls deploy --stage dev --region us-west-2 -v
swapping in your desiredstage
andregion
-
Create a BitBucket webhook copying the API URL printed in the terminal after deployment
-
Run
sls logs -f webhook --stage dev --region us-west-2 -t
to listen for logs -
Push a file into your BitBucket Repo and watch the Lambda log come through the terminal output
-
Navigate to GitHub repository to see the latest commit