Skip to content

Commit

Permalink
Merge pull request #3 from FIAP-3SOAT-G15/setup-infra
Browse files Browse the repository at this point in the history
Setup infra
  • Loading branch information
wellyfrs authored May 16, 2024
2 parents 60725ae + 079b1f6 commit e5f442e
Show file tree
Hide file tree
Showing 60 changed files with 216 additions and 5,722 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: App

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
app:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Verify
run: mvn verify -DskipITs=false

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build, tag, and push docker image to Amazon ECR
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ vars.AWS_ECR_REPO_NAME }}
IMAGE_TAG: "latest"
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
38 changes: 38 additions & 0 deletions .github/workflows/destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Destroy

on:
workflow_dispatch:

jobs:
destroy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: terraform
permissions:
id-token: write
contents: read
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
cli_config_credentials_token: ${{ secrets.TF_CLOUD_USER_API_TOKEN }}

- name: Terraform Init
run: terraform init

- name: Terraform Destroy
run: terraform destroy -auto-approve
69 changes: 69 additions & 0 deletions .github/workflows/provisioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Provisioning

on:
push:
branches:
- main
paths:
- .github/workflows/provisioning.yml
- 'terraform/**'
- 'src/**'
pull_request:
branches:
- main
paths:
- .github/workflows/provisioning.yml
- 'terraform/**'
- 'src/**'
workflow_dispatch:

jobs:
provisioning:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
permissions:
id-token: write
contents: read
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ vars.AWS_IAM_ROLE }}
aws-region: ${{ vars.AWS_REGION }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_CLOUD_USER_API_TOKEN }}

- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true

- name: Terraform Init
id: init
run: terraform init

- name: Terraform Validate
id: validate
run: terraform validate

- name: Terraform Plan
id: plan
run: terraform plan

- name: Check Errors
if: steps.plan.outcome == 'failure'
run: exit 1

- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false
10 changes: 0 additions & 10 deletions Dockerfile.docs

This file was deleted.

20 changes: 0 additions & 20 deletions Dockerfile.mapper

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Bleno Claus, Giovanni di Luca, Mateus Albino, Wellyson Freitas
Copyright (c) 2023 Bleno Claus, Giovanni di Luca, Lucas Gabriel, Mateus Albino, Wellyson Freitas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

Loading

0 comments on commit e5f442e

Please sign in to comment.