test unit #43
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 | |
| permissions: | |
| contents: read | |
| checks: write | |
| 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 | |
| # ------------------------------- | |
| # BUILD + TESTS + COVERAGE | |
| # ------------------------------- | |
| - name: Build with Tests and Coverage | |
| working-directory: app | |
| run: mvn -B clean verify | |
| # ------------------------------- | |
| # TEST REPORT | |
| # ------------------------------- | |
| - name: Publish Test Report | |
| uses: dorny/test-reporter@v1 | |
| if: always() | |
| with: | |
| name: Maven Tests | |
| path: app/target/surefire-reports/*.xml | |
| reporter: java-junit | |
| # ------------------------------- | |
| # COVERAGE REPORT | |
| # ------------------------------- | |
| - name: Upload Coverage Report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: app/target/site/jacoco | |
| # ------------------------------- | |
| # SHOW GENERATED JAR | |
| # ------------------------------- | |
| - name: List generated JAR | |
| run: ls -lh app/target/*.jar | |
| # ------------------------------- | |
| # UPLOAD 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_lambda_jar_path: app/target/lambda-identification-auth.jar | |
| - name: Terraform Apply | |
| run: terraform apply -auto-approve tfplan | |
| env: | |
| TF_VAR_lambda_jar_path: app/target/lambda-identification-auth.jar |