title |
---|
GitLab Pipelines + AWS |
-
AWS Lambda function needs to be configured first
-
GitLab webhook should be configured pointing to lambda's public url
-
Fork and clone this repo: https://github.com/diggerhq/gitlab-webhook-lambda.
-
If necessary, update the
serverless.yml
file in the cloned repository. This file contains configuration settings for the Lambda function and can be customized to suit your requirements. -
Save the
GITLAB_TOKEN
to the SSM (Systems Manager) parameter store. You can choose any path for storing the token, but ensure that theserverless.yml
file is updated accordingly if you deviate from the default path. For example, save theGITLAB_TOKEN
tossm:/gitlab-dev-webhook-handler/dev/GITLAB_TOKEN
. -
Do the same for SECRET_TOKEN, update serverless.yml if needed and save token value to ssm parameter (for example
ssm:/gitlab-dev-webhook-handler/dev/SECRET_TOKEN
) -
Make sure that your AWS credentials are properly configured in the command-line interface (CLI). This ensures that you have the necessary permissions to deploy the Lambda function.
-
Run the command
npm run build
in the root directory of the cloned repository. This command will build the necessary artifacts for the Lambda function. -
Finally, run the command
npm run deploy
in the same root directory. This will initiate the deployment process for the Lambda function using the configuration specified in theserverless.yml
file.
To configure the GitLab webhook, follow these steps:
-
Go to the repository's Settings and select WebHooks.
-
Copy the public URL of the Lambda function and paste it into the URL textbox.
-
Specify a Secret token for secure communication.
-
Tick the checkboxes for 'Comments' and 'Merge Request events' to enable the desired events.
-
Finally, click the 'Add webhook' button to save the configuration.