From d01b0140a26788ea71c0eb254845b253afda9cb4 Mon Sep 17 00:00:00 2001 From: horita-yuya Date: Wed, 20 Nov 2024 14:09:22 +0900 Subject: [PATCH] Add ci --- .github/workflows/Publish.yml | 37 +++++++++++++++++++++++++++++++++++ terraform/aws_lambda_layer.tf | 16 +++++++++++++++ terraform/main.tf | 19 ------------------ 3 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/Publish.yml create mode 100644 terraform/aws_lambda_layer.tf delete mode 100644 terraform/main.tf diff --git a/.github/workflows/Publish.yml b/.github/workflows/Publish.yml new file mode 100644 index 0000000..e54f7ec --- /dev/null +++ b/.github/workflows/Publish.yml @@ -0,0 +1,37 @@ +name: Build and Publish Artifacts + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build bootstrap + working-directory: ./bootstrap-go + run: make build + env: + CGO_ENABLED: 0 + + - name: Build index.js + working-directory: ./compute-type-value + run: yarn install && yarn build + + - name: Prepare runtime directory + run: | + mkdir -p artifacts + cp bootstrap-go/build/bootstrap artifacts/runtime/bootstrap + cp compute-type-value/dist/index.js artifacts/runtime/index.js + cp terraform/aws_lambda_layer.tf artifacts/aws_lambda_layer.tf + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: runtime-artifacts + path: artifacts \ No newline at end of file diff --git a/terraform/aws_lambda_layer.tf b/terraform/aws_lambda_layer.tf new file mode 100644 index 0000000..52a3adb --- /dev/null +++ b/terraform/aws_lambda_layer.tf @@ -0,0 +1,16 @@ +locals { + # Type-Level Runtime + runtime_name = "tlrt" +} + +resource "aws_lambda_layer_version" "tlrt" { + layer_name = local.runtime_name + filename = "${path.module}/${local.runtime_name}.zip" +} + +data "archive_file" "lambda" { + type = "zip" + output_path = "${path.module}/${local.runtime_name}.zip" + + source_dir = "${path.module}/runtime" +} \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf deleted file mode 100644 index aaf664f..0000000 --- a/terraform/main.tf +++ /dev/null @@ -1,19 +0,0 @@ -resource "aws_lambda_function" "sample" { - function_name = "tlrt-sample" - role = data.aws_iam_policy_document.assume_role.json - - runtime = "provided.al2023" -} - -data "aws_iam_policy_document" "assume_role" { - statement { - effect = "Allow" - - principals { - type = "Service" - identifiers = ["lambda.amazonaws.com"] - } - - actions = ["sts:AssumeRole"] - } -} \ No newline at end of file