removes circleci deployment workflow && add the github actions workflow #7
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: Build and Deploy Spring Boot Application to Azure | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the code | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| # Step 2: Set up JDK 17 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: "17" | |
| distribution: "adopt" | |
| # Step 3: Build the application with Maven | |
| - name: Build with Maven | |
| working-directory: ./backend | |
| run: mvn clean package -DskipTests | |
| # Step 4: Log in to Azure Container Registry (ACR) | |
| - name: Log in to Azure Container Registry | |
| uses: azure/docker-login@v1 | |
| with: | |
| login-server: ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }} | |
| username: ${{ secrets.AZURE_REGISTRY_USERNAME }} | |
| password: ${{ secrets.AZURE_REGISTRY_PASSWORD }} | |
| # Step 5: Build Docker image | |
| - name: Build Docker image | |
| working-directory: ./backend | |
| run: docker build -t ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/marketspy-backend:${{ github.sha }} . | |
| # Step 6: Push Docker image to ACR | |
| - name: Push Docker image to ACR | |
| run: docker push ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/marketspy-backend:${{ github.sha }} | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| # Step 1: Login to Azure | |
| - name: Azure CLI login | |
| run: az login | |
| # Step 2: Install Azure Spring CLI extension | |
| - name: Install Azure Spring extension | |
| run: az extension add --name spring | |
| # Step 3: Deploy the Docker image to Azure Spring Apps | |
| - name: Deploy to Azure Spring Apps | |
| run: | | |
| az spring app deploy --name marketspy --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --service ${{ secrets.AZURE_SPRING_SERVICE }} --container-registry ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }} --container-image ${{ secrets.AZURE_REGISTRY_LOGIN_SERVER }}/marketspy-backend:${{ github.sha }} |