From 4752f8021eb2664d2e85dd3753216f72ccdf7f67 Mon Sep 17 00:00:00 2001 From: m7kvqbe1 <48086589+m7kvqbe1@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:19:15 +0000 Subject: [PATCH] Add GHA workflow to deploy to AWS Lambda serverless --- .github/workflows/{go.yml => build_test.yml} | 2 +- .github/workflows/deploy.yml | 37 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) rename .github/workflows/{go.yml => build_test.yml} (95%) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/go.yml b/.github/workflows/build_test.yml similarity index 95% rename from .github/workflows/go.yml rename to .github/workflows/build_test.yml index 71d42bc..8bf5f68 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/build_test.yml @@ -1,4 +1,4 @@ -name: Go Build +name: Build & Test on: [push] diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..ec4c8ee --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,37 @@ +name: Deploy to AWS Lambda + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.22.1 + + - name: Build Go application + run: | + GOOS=linux GOARCH=amd64 go build -o main main.go + zip deployment.zip main + + - 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: ${{ secrets.AWS_REGION }} + + - name: Deploy to AWS Lambda + run: | + aws lambda update-function-code --function-name GoTicketPolling --zip-file fileb://deployment.zip + + - name: Clean up + run: rm main deployment.zip