fix sg #40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Lambda to AWS | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| TF_WORKSPACE: default | |
| AWS_REGION: us-east-1 | |
| jobs: | |
| # ========================================================= | |
| # BUILD | |
| # ========================================================= | |
| build: | |
| name: Build Lambda | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: temurin | |
| cache: maven | |
| - name: Build fat JAR | |
| working-directory: app | |
| run: | | |
| mvn -B clean package -DskipTests | |
| ls -lh target/*.jar | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: lambda-jar | |
| path: app/target/*.jar | |
| # ========================================================= | |
| # DEPLOY | |
| # ========================================================= | |
| deploy: | |
| name: Deploy Lambda + Infra | |
| runs-on: ubuntu-latest | |
| needs: build | |
| environment: Production | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: lambda-jar | |
| path: app/target | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_ACCESS_SECRET }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Setup Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| - name: Terraform Init | |
| run: terraform init | |
| - name: Terraform Plan | |
| run: terraform plan -out=tfplan | |
| env: | |
| TF_VAR_db_user: ${{ secrets.DB_USER }} | |
| TF_VAR_db_password: ${{ secrets.DB_PASSWORD }} | |
| TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET_KEY }} | |
| TF_VAR_lambda_jar_path: app/target/lambda-identification-auth.jar | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve tfplan | |
| env: | |
| TF_VAR_db_user: ${{ secrets.DB_USER }} | |
| TF_VAR_db_password: ${{ secrets.DB_PASSWORD }} | |
| TF_VAR_jwt_secret: ${{ secrets.JWT_SECRET_KEY }} | |
| TF_VAR_lambda_jar_path: app/target/lambda-identification-auth.jar |