Skip to content

Commit

Permalink
build deploy update ynab
Browse files Browse the repository at this point in the history
  • Loading branch information
rhyek committed Apr 1, 2024
1 parent 49bea60 commit 5c648d2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
38 changes: 36 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ jobs:
working-directory: ./projects/scrape-txs
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_DEFAULT_REGION }}
- name: Set build params
- name: Set build/deploy params
run: |
echo "ECR_REPO_URL=${{ needs.terraform.outputs.ecr_repository_scrape_txs_url }}" >> $GITHUB_ENV
echo "LAMBDA_ROLE_ARN=${{ needs.terraform.outputs.iam_lambda_role_arn }}" >> $GITHUB_ENV
Expand All @@ -99,3 +99,37 @@ jobs:
run: |
cd ./deploy
serverless deploy
deploy-update-ynab:
name: Deoloy Update YNAB
runs-on: ubuntu-22.04
needs: terraform
defaults:
run:
working-directory: ./projects/update-ynab
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '^1.22.1'
- name: Build
run: make build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_DEFAULT_REGION }}
- name: Set deploy params
run: |
echo "LAMBDA_ROLE_ARN=${{ needs.terraform.outputs.iam_lambda_role_arn }}" >> $GITHUB_ENV
- name: Deploy
run: |
aws lambda create-function --function-name update-ynab-fn \
--runtime provided.al2023 \
--handler bootstrap \
--architectures arm64 \
--role ${{ needs.terraform.outputs.iam_lambda_role_arn }} \
--zip-file fileb://update-ynab.zip
1 change: 1 addition & 0 deletions projects/update-ynab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bootstrap
19 changes: 19 additions & 0 deletions projects/update-ynab/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
test:
go test ./...
build: # https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html
GOOS=linux GOARCH=arm64 go build -tags lambda.norpc -o bootstrap main.go
zip update-ynab.zip bootstrap
deploy:
function_name="update-ynab-fn"
if aws lambda get-function --function-name $function_name --region us-east-1 &> /dev/null
then
echo "Updating function"
aws lambda update-function-code --function-name $function_name \
--zip-file fileb://update-ynab.zip
else
echo "Creating function"
aws lambda create-function --function-name $function_name \
--runtime provided.al2023 \
--handler bootstrap \
--architectures arm64 \
--role $LAMBDA_ROLE_ARN \
--zip-file fileb://update-ynab.zip
fi

0 comments on commit 5c648d2

Please sign in to comment.