diff --git a/.github/workflows/continuos_integrations.yaml b/.github/workflows/continuos_integrations.yaml new file mode 100644 index 0000000..295a1d6 --- /dev/null +++ b/.github/workflows/continuos_integrations.yaml @@ -0,0 +1,20 @@ +name: Continuous Integration +on: + pull_request: + types: [opened, reopened] + branches: "feature/**" +jobs: + tests: + runs-on: ubuntu-latest + steps: + - + name: Git Checkout + uses: actions/checkout@v4 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + - name: Unit tests + run: mvn test \ No newline at end of file diff --git a/README.md b/README.md index 541f35a..b4b1851 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Simple API Java -Aplicação API +Aplicação API. ## Pré-requisitos diff --git a/compose.yaml b/compose.yaml index b7dc1b5..8ac97d6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,18 +1,52 @@ -services: - db: - container_name: mysql - image: "mysql" - ports: - - "3306:3306" - environment: - - MYSQL_ROOT_PASSWORD=root_pass - - api: - build: . - ports: - - "8080:8080" - environment: - - PROFILE=dev - - DATABASE_URL=jdbc:mysql://db:3306/api?createDatabaseIfNotExist=true - - DATABASE_USER=root - - DATABASE_PWD=root_pass +name: Continuous Delivery + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Setup Java SDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '22' + + - name: Verify Environment Variables + run: | + echo "Docker Hub Username: ${{ secrets.DOCKERHUB_USERNAME }}" + echo "Azure Web App Name: ${{ env.AZURE_WEBAPP_NAME }}" + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v6 + with: + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest + + deploy: + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to Azure Web App + id: deploy-to-webapp + uses: azure/webapps-deploy@v2 + with: + app-name: ${{ env.AZURE_WEBAPP_NAME }} + publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} + images: '${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest'