|
6 | 6 | pull_request: |
7 | 7 | branches: ["main"] |
8 | 8 |
|
| 9 | +permissions: |
| 10 | + id-token: write |
| 11 | + contents: read |
| 12 | + |
9 | 13 | jobs: |
10 | 14 | backend-build: |
11 | 15 | name: Backend Build (Spring Boot) |
|
86 | 90 | context: ./frontend |
87 | 91 | push: false |
88 | 92 | tags: cloudpulse-frontend:ci |
| 93 | + |
| 94 | + backend-ecr-push: |
| 95 | + name: Push Backend Image to ECR |
| 96 | + runs-on: ubuntu-latest |
| 97 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 98 | + |
| 99 | + steps: |
| 100 | + - name: Checkout repo |
| 101 | + uses: actions/checkout@v4 |
| 102 | + |
| 103 | + - name: Configure AWS credentials (OIDC) |
| 104 | + uses: aws-actions/configure-aws-credentials@v4 |
| 105 | + with: |
| 106 | + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} |
| 107 | + aws-region: ${{ secrets.AWS_REGION }} |
| 108 | + |
| 109 | + - name: Login to Amazon ECR |
| 110 | + id: login-ecr |
| 111 | + uses: aws-actions/amazon-ecr-login@v2 |
| 112 | + |
| 113 | + - name: Set up Docker Buildx |
| 114 | + uses: docker/setup-buildx-action@v3 |
| 115 | + |
| 116 | + - name: Build and push backend |
| 117 | + uses: docker/build-push-action@v6 |
| 118 | + with: |
| 119 | + context: ./backend |
| 120 | + push: true |
| 121 | + tags: | |
| 122 | + ${{ steps.login-ecr.outputs.registry }}/cloudpulse-backend:${{ github.sha }} |
| 123 | + ${{ steps.login-ecr.outputs.registry }}/cloudpulse-backend:latest |
| 124 | +
|
| 125 | + frontend-ecr-push: |
| 126 | + name: Push Frontend Image to ECR |
| 127 | + runs-on: ubuntu-latest |
| 128 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 129 | + |
| 130 | + steps: |
| 131 | + - name: Checkout repo |
| 132 | + uses: actions/checkout@v4 |
| 133 | + |
| 134 | + - name: Configure AWS credentials (OIDC) |
| 135 | + uses: aws-actions/configure-aws-credentials@v4 |
| 136 | + with: |
| 137 | + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} |
| 138 | + aws-region: ${{ secrets.AWS_REGION }} |
| 139 | + |
| 140 | + - name: Login to Amazon ECR |
| 141 | + id: login-ecr |
| 142 | + uses: aws-actions/amazon-ecr-login@v2 |
| 143 | + |
| 144 | + - name: Set up Docker Buildx |
| 145 | + uses: docker/setup-buildx-action@v3 |
| 146 | + |
| 147 | + - name: Build and push frontend |
| 148 | + uses: docker/build-push-action@v6 |
| 149 | + with: |
| 150 | + context: ./frontend |
| 151 | + push: true |
| 152 | + tags: | |
| 153 | + ${{ steps.login-ecr.outputs.registry }}/cloudpulse-frontend:${{ github.sha }} |
| 154 | + ${{ steps.login-ecr.outputs.registry }}/cloudpulse-frontend:latest |
0 commit comments