|
46 | 46 | - name: Checkout code |
47 | 47 | uses: actions/checkout@v5 |
48 | 48 | with: |
49 | | - ref: ${{ env.BRANCH_NAME }} |
50 | 49 | fetch-depth: 0 |
51 | 50 |
|
52 | 51 | # Must be done before anything installs, or it will check dependencies for secrets too. |
@@ -367,137 +366,129 @@ jobs: |
367 | 366 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
368 | 367 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
369 | 368 |
|
370 | | - build_dev_container_cross_compile: |
| 369 | + build_dev_container_x64: |
371 | 370 | runs-on: ubuntu-22.04 |
| 371 | + if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }} |
372 | 372 | steps: |
373 | 373 | - name: Checkout code |
374 | 374 | uses: actions/checkout@v5 |
375 | 375 | with: |
376 | | - ref: ${{ env.BRANCH_NAME }} |
377 | 376 | fetch-depth: 0 |
378 | 377 |
|
379 | 378 | - name: Build dev container |
380 | 379 | run: | |
381 | | - docker buildx create --use |
382 | | - docker buildx build --platform linux/amd64,linux/arm64 -f .devcontainer/Dockerfile -t dev-container-image . |
383 | | - # - name: Configure AWS Credentials |
384 | | - # uses: aws-actions/configure-aws-credentials@v5 |
385 | | - # id: connect-aws-deploy |
386 | | - # with: |
387 | | - # aws-region: eu-west-2 |
388 | | - # role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
389 | | - # role-session-name: dev-container-build |
390 | | - # output-credentials: true |
391 | | - |
392 | | - # - name: Retrieve AWS Account ID |
393 | | - # id: retrieve-deploy-account-id |
394 | | - # run: echo "ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_ENV" |
395 | | - |
396 | | - # - name: Login to Amazon ECR |
397 | | - # id: login-ecr-push-image |
398 | | - # run: | |
399 | | - # aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com |
400 | | - |
401 | | - # - name: Push FHIR Facade image to Amazon ECR |
402 | | - # run: | |
403 | | - # docker tag "dev-container-image" "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
404 | | - # docker push "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
405 | | - |
406 | | - # - name: Check dev container scan results |
407 | | - # env: |
408 | | - # REPOSITORY_NAME: ${{inputs.DEV_CONTAINER_ECR}} |
409 | | - # IMAGE_TAG: ${{ inputs.DEV_CONTAINER_IMAGE_TAG }} |
410 | | - # working-directory: .github/scripts |
411 | | - # run: | |
412 | | - # ./check_ecr_image_scan_results.sh |
413 | | - build_dev_container_x64: |
414 | | - runs-on: ubuntu-22.04 |
415 | | - steps: |
416 | | - - name: Checkout code |
417 | | - uses: actions/checkout@v5 |
| 380 | + docker build -f .devcontainer/Dockerfile -t dev-container-image . |
| 381 | +
|
| 382 | + - name: Configure AWS Credentials |
| 383 | + uses: aws-actions/configure-aws-credentials@v5 |
| 384 | + id: connect-aws-deploy |
418 | 385 | with: |
419 | | - ref: ${{ env.BRANCH_NAME }} |
420 | | - fetch-depth: 0 |
| 386 | + aws-region: eu-west-2 |
| 387 | + role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
| 388 | + role-session-name: dev-container-build-x64 |
| 389 | + output-credentials: true |
421 | 390 |
|
422 | | - - name: Build dev container |
| 391 | + - name: Retrieve AWS Account ID |
| 392 | + id: retrieve-deploy-account-id |
423 | 393 | run: | |
424 | | - docker build -f .devcontainer/Dockerfile -t dev-container-image . |
425 | | - # - name: Configure AWS Credentials |
426 | | - # uses: aws-actions/configure-aws-credentials@v5 |
427 | | - # id: connect-aws-deploy |
428 | | - # with: |
429 | | - # aws-region: eu-west-2 |
430 | | - # role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
431 | | - # role-session-name: dev-container-build |
432 | | - # output-credentials: true |
433 | | - |
434 | | - # - name: Retrieve AWS Account ID |
435 | | - # id: retrieve-deploy-account-id |
436 | | - # run: echo "ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_ENV" |
437 | | - |
438 | | - # - name: Login to Amazon ECR |
439 | | - # id: login-ecr-push-image |
440 | | - # run: | |
441 | | - # aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com |
442 | | - |
443 | | - # - name: Push FHIR Facade image to Amazon ECR |
444 | | - # run: | |
445 | | - # docker tag "dev-container-image" "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
446 | | - # docker push "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
447 | | - |
448 | | - # - name: Check dev container scan results |
449 | | - # env: |
450 | | - # REPOSITORY_NAME: ${{inputs.DEV_CONTAINER_ECR}} |
451 | | - # IMAGE_TAG: ${{ inputs.DEV_CONTAINER_IMAGE_TAG }} |
452 | | - # working-directory: .github/scripts |
453 | | - # run: | |
454 | | - # ./check_ecr_image_scan_results.sh |
| 394 | + ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) |
| 395 | + echo "account_id=$ACCOUNT_ID" >> "$GITHUB_OUTPUT" |
| 396 | +
|
| 397 | + - name: Login to Amazon ECR |
| 398 | + run: | |
| 399 | + aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com |
| 400 | +
|
| 401 | + - name: Push x64 image to Amazon ECR |
| 402 | + run: | |
| 403 | + docker tag "dev-container-image" "${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64" |
| 404 | + docker push "${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64" |
455 | 405 |
|
456 | 406 | build_dev_container_arm64: |
457 | 407 | runs-on: ubuntu-22.04-arm |
| 408 | + if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }} |
458 | 409 | steps: |
459 | 410 | - name: Checkout code |
460 | 411 | uses: actions/checkout@v5 |
461 | 412 | with: |
462 | | - ref: ${{ env.BRANCH_NAME }} |
463 | 413 | fetch-depth: 0 |
464 | 414 |
|
465 | 415 | - name: Build dev container |
466 | 416 | run: | |
467 | 417 | docker build -f .devcontainer/Dockerfile -t dev-container-image-arm . |
468 | | - docker save "dev-container-image-arm" -o dev-container-image-arm.img |
469 | | - - uses: actions/upload-artifact@v4 |
470 | | - name: upload build artifact |
| 418 | +
|
| 419 | + - name: Configure AWS Credentials |
| 420 | + uses: aws-actions/configure-aws-credentials@v5 |
| 421 | + id: connect-aws-deploy |
471 | 422 | with: |
472 | | - name: dev-container-image-arm |
473 | | - path: dev-container-image-arm.img |
474 | | - # - name: Configure AWS Credentials |
475 | | - # uses: aws-actions/configure-aws-credentials@v5 |
476 | | - # id: connect-aws-deploy |
477 | | - # with: |
478 | | - # aws-region: eu-west-2 |
479 | | - # role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
480 | | - # role-session-name: dev-container-build |
481 | | - # output-credentials: true |
482 | | - |
483 | | - # - name: Retrieve AWS Account ID |
484 | | - # id: retrieve-deploy-account-id |
485 | | - # run: echo "ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)" >> "$GITHUB_ENV" |
486 | | - |
487 | | - # - name: Login to Amazon ECR |
488 | | - # id: login-ecr-push-image |
489 | | - # run: | |
490 | | - # aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com |
491 | | - |
492 | | - # - name: Push FHIR Facade image to Amazon ECR |
493 | | - # run: | |
494 | | - # docker tag "dev-container-image" "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
495 | | - # docker push "${{ env.ACCOUNT_ID }}.dkr.ecr.eu-west-2.amazonaws.com/${{inputs.DEV_CONTAINER_ECR}}:${{ inputs.DEV_CONTAINER_IMAGE_TAG }}" |
496 | | - |
497 | | - # - name: Check dev container scan results |
498 | | - # env: |
499 | | - # REPOSITORY_NAME: ${{inputs.DEV_CONTAINER_ECR}} |
500 | | - # IMAGE_TAG: ${{ inputs.DEV_CONTAINER_IMAGE_TAG }} |
501 | | - # working-directory: .github/scripts |
502 | | - # run: | |
503 | | - # ./check_ecr_image_scan_results.sh |
| 423 | + aws-region: eu-west-2 |
| 424 | + role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
| 425 | + role-session-name: dev-container-build-arm64 |
| 426 | + output-credentials: true |
| 427 | + |
| 428 | + - name: Retrieve AWS Account ID |
| 429 | + id: retrieve-deploy-account-id |
| 430 | + run: | |
| 431 | + ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) |
| 432 | + echo "account_id=$ACCOUNT_ID" >> "$GITHUB_OUTPUT" |
| 433 | +
|
| 434 | + - name: Login to Amazon ECR |
| 435 | + run: | |
| 436 | + aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com |
| 437 | +
|
| 438 | + - name: Push ARM64 image to Amazon ECR |
| 439 | + run: | |
| 440 | + docker tag "dev-container-image-arm" "${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-arm64" |
| 441 | + docker push "${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-arm64" |
| 442 | +
|
| 443 | + create_multi_arch_manifest: |
| 444 | + runs-on: ubuntu-22.04 |
| 445 | + needs: [build_dev_container_x64, build_dev_container_arm64] |
| 446 | + if: ${{ inputs.dev_container_ecr != '' && inputs.dev_container_image_tag != '' }} |
| 447 | + steps: |
| 448 | + - name: Set up Docker Buildx |
| 449 | + uses: docker/setup-buildx-action@v3 |
| 450 | + |
| 451 | + - name: Configure AWS Credentials |
| 452 | + uses: aws-actions/configure-aws-credentials@v5 |
| 453 | + with: |
| 454 | + aws-region: eu-west-2 |
| 455 | + role-to-assume: ${{ secrets.CLOUD_FORMATION_DEPLOY_ROLE }} |
| 456 | + role-session-name: multi-arch-manifest |
| 457 | + output-credentials: true |
| 458 | + |
| 459 | + - name: Retrieve AWS Account ID |
| 460 | + id: retrieve-deploy-account-id |
| 461 | + run: | |
| 462 | + ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) |
| 463 | + echo "account_id=$ACCOUNT_ID" >> "$GITHUB_OUTPUT" |
| 464 | +
|
| 465 | + - name: Login to Amazon ECR |
| 466 | + run: | |
| 467 | + aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com |
| 468 | +
|
| 469 | + - name: Create and push multi-architecture manifest |
| 470 | + run: | |
| 471 | + # Create manifest list combining both architectures |
| 472 | + docker buildx imagetools create -t ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }} \ |
| 473 | + ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64 \ |
| 474 | + ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-arm64 |
| 475 | +
|
| 476 | + # Also create latest tag |
| 477 | + docker buildx imagetools create -t ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:latest \ |
| 478 | + ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-amd64 \ |
| 479 | + ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }}-arm64 |
| 480 | +
|
| 481 | + - name: Verify multi-architecture manifest |
| 482 | + run: | |
| 483 | + echo "=== Verifying multi-architecture manifest ===" |
| 484 | + docker buildx imagetools inspect ${{ steps.retrieve-deploy-account-id.outputs.account_id }}.dkr.ecr.eu-west-2.amazonaws.com/${{ inputs.dev_container_ecr }}:${{ inputs.dev_container_image_tag }} |
| 485 | +
|
| 486 | + - name: Check dev container scan results |
| 487 | + env: |
| 488 | + REPOSITORY_NAME: ${{ inputs.dev_container_ecr }} |
| 489 | + IMAGE_TAG: ${{ inputs.dev_container_image_tag }} |
| 490 | + working-directory: .github/scripts |
| 491 | + run: | |
| 492 | + # Wait a moment for ECR to process the new manifest |
| 493 | + sleep 30 |
| 494 | + ./check_ecr_image_scan_results.sh |
0 commit comments