mirror of
https://github.com/Hestia-Homes/survey-extraction.git
synced 2026-06-30 13:10:56 +00:00
dynamic tagging
This commit is contained in:
parent
2ebd8b8ff3
commit
f9baf95295
6 changed files with 29 additions and 8 deletions
|
|
@ -23,6 +23,12 @@ inputs:
|
|||
aws-region:
|
||||
description: "AWS region"
|
||||
required: true
|
||||
git-sha:
|
||||
description: "Git commit SHA"
|
||||
required: true
|
||||
git-ref:
|
||||
description: "Git ref name"
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
|
@ -47,11 +53,19 @@ runs:
|
|||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
||||
aws-region: ${{ inputs.aws-region }}
|
||||
- name: Set Docker image tag
|
||||
id: set_tag
|
||||
run: |
|
||||
SHORT_SHA=$(echo "${{ inputs.git-sha }}" | cut -c1-7)
|
||||
BRANCH=$(echo "${{ inputs.git-ref }}" | tr '/' '-')
|
||||
TAG="${BRANCH}-${SHORT_SHA}"
|
||||
echo "IMAGE_TAG=${TAG}" >> $GITHUB_ENV
|
||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Build and push Docker image
|
||||
shell: bash
|
||||
run: |
|
||||
IMAGE_URI=${{ steps.login-ecr.outputs.registry }}/${{ inputs.lambda_name }}:latest
|
||||
IMAGE_URI=${{ steps.login-ecr.outputs.registry }}/${{ inputs.lambda_name }}:${{ steps.set_tag.outputs.tag }}
|
||||
echo "Building Docker image for ${{ inputs.lambda_name }}..."
|
||||
docker build -t $IMAGE_URI -f ${{ inputs.dockerfile_path }} .
|
||||
|
||||
|
|
@ -65,5 +79,7 @@ runs:
|
|||
aws-access-key-id: ${{ inputs.aws-access-key-id }}
|
||||
aws-secret-access-key: ${{ inputs.aws-secret-access-key }}
|
||||
aws-region: ${{ inputs.aws-region }}
|
||||
lambda-image-tag: ${{ steps.set_tag.outputs.tag }}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ inputs:
|
|||
aws-region:
|
||||
description: "AWS region"
|
||||
required: true
|
||||
lambda-image-tag:
|
||||
description: "Tag of the Lambda image (e.g., GitHub SHA)"
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
|
|
@ -38,7 +41,8 @@ runs:
|
|||
- name: Terraform Plan
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
shell: bash
|
||||
run: terraform plan -out=tfplan
|
||||
run: terraform plan -out=tfplan -var="lambda_image_tag=${{ inputs.lambda-image-tag }}"
|
||||
|
||||
|
||||
- name: Terraform Apply
|
||||
working-directory: ${{ inputs.working_directory }}
|
||||
|
|
|
|||
4
.github/workflows/lambda_main.yml
vendored
4
.github/workflows/lambda_main.yml
vendored
|
|
@ -41,6 +41,8 @@ jobs:
|
|||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
git-sha: ${{ github.sha }}
|
||||
git-ref: ${{ github.ref_name }}
|
||||
|
||||
extractor-and-loader:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
@ -62,4 +64,6 @@ jobs:
|
|||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: ${{ secrets.AWS_REGION }}
|
||||
git-sha: ${{ github.sha }}
|
||||
git-ref: ${{ github.ref_name }}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ variable allocated_storage {
|
|||
description = "The allocated storage in gigabytes"
|
||||
type = number
|
||||
default = 20
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ resource "aws_lambda_function" "extractor_and_loader" {
|
|||
function_name = "extractor-and-loader"
|
||||
role = data.aws_iam_role.lambda_exec_role.arn
|
||||
package_type = "Image"
|
||||
image_uri = "${data.aws_ecr_repository.extractor_and_loader.repository_url}:latest"
|
||||
image_uri = "${data.aws_ecr_repository.extractor_and_loader.repository_url}:${var.lambda_image_tag}"
|
||||
timeout = 30
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +69,3 @@ resource "aws_lambda_event_source_mapping" "extractor_and_loader_trigger" {
|
|||
batch_size = 1
|
||||
}
|
||||
|
||||
|
||||
# TODO: Seperate lambda jobs from ecr creation. This is because we need to
|
||||
# Create the ecr, then push images, then lambda jobs can be made
|
||||
|
|
@ -57,7 +57,7 @@ resource "aws_lambda_function" "lambda_example" {
|
|||
function_name = "lambda-example"
|
||||
role = data.aws_iam_role.lambda_exec_role.arn
|
||||
package_type = "Image"
|
||||
image_uri = "${data.aws_ecr_repository.lambda_example.repository_url}:latest"
|
||||
image_uri = "${data.aws_ecr_repository.lambda_example.repository_url}:${var.lambda_image_tag}"
|
||||
timeout = 10
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue