|
1 | | -name: Python Tests |
| 1 | +name: CI/CD |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [ "main" ] |
6 | 6 | pull_request: |
7 | | - branches: [ "**"] # Adjust branches as needed |
| 7 | + branches: [ "**" ] # Adjust branches as needed |
| 8 | + release: |
| 9 | + types: [published] |
| 10 | + |
| 11 | +permissions: |
| 12 | + id-token: write # Required for OIDC |
| 13 | + contents: read # Required for checkout |
8 | 14 |
|
9 | 15 | jobs: |
10 | 16 | test: |
|
45 | 51 | start-runner: |
46 | 52 | name: Start self-hosted EC2 runner |
47 | 53 | runs-on: ubuntu-24.04 |
| 54 | + needs: test |
48 | 55 | outputs: |
49 | 56 | label: ${{ steps.start-ec2-runner.outputs.label }} |
50 | 57 | ec2-instances-ids: ${{ steps.start-ec2-runner.outputs.ec2-instances-ids }} |
@@ -168,3 +175,50 @@ jobs: |
168 | 175 | github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} |
169 | 176 | label: ${{ needs.start-runner.outputs.label }} |
170 | 177 | ec2-instances-ids: ${{ needs.start-runner.outputs.ec2-instances-ids }} |
| 178 | + |
| 179 | + deploy-images: |
| 180 | + name: Publish ${{ matrix.component }} to ECR |
| 181 | + needs: e2e-tests |
| 182 | + if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' |
| 183 | + runs-on: ubuntu-latest |
| 184 | + strategy: |
| 185 | + matrix: |
| 186 | + include: |
| 187 | + - component: vllm |
| 188 | + docker_build_extra_args: "" |
| 189 | + - component: attestation |
| 190 | + docker_build_extra_args: "" |
| 191 | + - component: api |
| 192 | + docker_build_extra_args: "--target nilai --platform linux/amd64" |
| 193 | + steps: |
| 194 | + - uses: actions/checkout@v4 |
| 195 | + |
| 196 | + - uses: aws-actions/configure-aws-credentials@v4 |
| 197 | + with: |
| 198 | + role-to-assume: "arn:aws:iam::054037142884:role/nilai-github" |
| 199 | + aws-region: "us-east-1" |
| 200 | + |
| 201 | + - uses: aws-actions/amazon-ecr-login@v2 |
| 202 | + id: login-ecr |
| 203 | + with: |
| 204 | + registry-type: public |
| 205 | + |
| 206 | + - uses: docker/setup-buildx-action@v3 |
| 207 | + |
| 208 | + - name: Build and push ${{ matrix.component }} image |
| 209 | + env: |
| 210 | + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} |
| 211 | + ECR_REGISTRY_ALIAS: k5d9x2g2 |
| 212 | + ECR_REPOSITORY: nilai-${{ matrix.component }} |
| 213 | + IMAGE_TAG: ${{ github.event_name == 'release' && github.ref_name || github.sha }} |
| 214 | + run: | |
| 215 | + ECR_REGISTRY_URL="${ECR_REGISTRY}/${ECR_REGISTRY_ALIAS}/${ECR_REPOSITORY}" |
| 216 | +
|
| 217 | + docker build \ |
| 218 | + --push \ |
| 219 | + -f docker/${{ matrix.component }}.Dockerfile \ |
| 220 | + -t ${ECR_REGISTRY_URL}:${IMAGE_TAG} \ |
| 221 | + ${{ matrix.docker_build_extra_args }} \ |
| 222 | + . |
| 223 | +
|
| 224 | + echo "Pushed ${{ matrix.component }} image: ${ECR_REGISTRY_URL}:${IMAGE_TAG}" >> $GITHUB_STEP_SUMMARY |
0 commit comments