diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml new file mode 100644 index 0000000..15ad832 --- /dev/null +++ b/.github/workflows/aws.yml @@ -0,0 +1,39 @@ +name: AWS Deploy + +# on: +# push: +# branches: +# - main + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - uses: pnpm/action-setup@v4 + name: Install pnpm + with: + version: 9 + run_install: false + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "pnpm" + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + - 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: us-west-2 # Best region according to AWS + - name: install & run + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + run: | + make build + make deploy-aws diff --git a/Makefile b/Makefile index 0f28714..22d720f 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,13 @@ localstack-reset: @echo "Resetting LocalStack..." @localstack state reset +deploy-aws: + @echo "Deploying apps with Terraform to AWS..." + @cd ./apps/server/.output/server && zip -r ./lambda.zip . && cd - + @cp ./apps/server/.output/server/lambda.zip ./.iac/terraform + @terraform -chdir=./.iac/terraform init + @terraform -chdir=./.iac/terraform apply --auto-approve + localstack-deploy-terraform: @echo "Locally deploying apps with Terraform..." @localstack wait