|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - main |
| 8 | +# Environment variables available to all jobs and steps in this workflow |
| 9 | +env: |
| 10 | + ANGULAR_IMAGE_NAME: social-login-app-client |
| 11 | + ANGULAR_CONTAINER_NAME: social-login-app-client |
| 12 | + ANGULAR_DEPLOYMENT_NAME: social-login-app-client |
| 13 | + SPRING_BOOT_IMAGE_NAME: social-login-app-server |
| 14 | + SPRING_BOOT_CONTAINER_NAME: social-login-app-server |
| 15 | + SPRING_BOOT_DEPLOYMENT_NAME: social-login-app-server |
| 16 | +jobs: |
| 17 | + |
| 18 | + build: |
| 19 | + name: Build, push, and deploy |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + |
| 23 | + - name: Checkout main |
| 24 | + uses: actions/checkout@main |
| 25 | + |
| 26 | + - name: Login to Docker Hub |
| 27 | + uses: docker/login-action@v1 |
| 28 | + with: |
| 29 | + username: ${{ secrets.DOCKER_HUB_USERNAME }} |
| 30 | + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
| 31 | + |
| 32 | + - name: Provide permission to run mvnw |
| 33 | + run: chmod +x ./spring-boot-oauth2-social-login/mvnw |
| 34 | + |
| 35 | + - name: Build and push Angular Image |
| 36 | + id: angular_docker_build |
| 37 | + uses: docker/build-push-action@v2 |
| 38 | + with: |
| 39 | + context: ./angular-11-social-login |
| 40 | + file: ./angular-11-social-login/Dockerfile |
| 41 | + push: true |
| 42 | + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.ANGULAR_IMAGE_NAME }}:${{ github.sha }} |
| 43 | + |
| 44 | + - name: Build and push Spring Boot Image |
| 45 | + id: spring-boot-docker_build |
| 46 | + uses: docker/build-push-action@v2 |
| 47 | + with: |
| 48 | + context: ./spring-boot-oauth2-social-login |
| 49 | + file: ./spring-boot-oauth2-social-login/Dockerfile |
| 50 | + push: true |
| 51 | + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.SPRING_BOOT_IMAGE_NAME }}:${{ github.sha }} |
| 52 | + |
| 53 | + - name: Install doctl |
| 54 | + uses: digitalocean/action-doctl@v2 |
| 55 | + with: |
| 56 | + token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }} |
| 57 | + |
| 58 | + - name: Save DigitalOcean kubeconfig with short-lived credentials |
| 59 | + run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 k8s-1-20-2-do-0-blr1-1619022201280 |
| 60 | + |
| 61 | + # Deploy Angular & Spring Boot Docker image to the DigitalOcean kubernetes cluster |
| 62 | + - name: Deploy |
| 63 | + run: |- |
| 64 | + kubectl set image deployment/${{env.ANGULAR_DEPLOYMENT_NAME}} ${{env.ANGULAR_CONTAINER_NAME}}=${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.ANGULAR_IMAGE_NAME }}:${{ github.sha }} |
| 65 | + kubectl set image deployment/${{env.SPRING_BOOT_DEPLOYMENT_NAME}} ${{ env.SPRING_BOOT_CONTAINER_NAME}}=${{ secrets.DOCKER_HUB_USERNAME }}/${{ env.SPRING_BOOT_IMAGE_NAME }}:${{ github.sha }} |
| 66 | + kubectl rollout status deployment/${{env.ANGULAR_DEPLOYMENT_NAME}} |
| 67 | + kubectl rollout status deployment/${{env.SPRING_BOOT_DEPLOYMENT_NAME}} |
| 68 | + kubectl get services -o wide |
0 commit comments