|
| 1 | +name: "Push Image" |
| 2 | +description: "Deploys the controller image into a given region" |
| 3 | + |
| 4 | +inputs: |
| 5 | + src_host: |
| 6 | + description: "URL of the source ECR repository to pull images from" |
| 7 | + required: true |
| 8 | + src_image_name: |
| 9 | + description: "Name of the source image" |
| 10 | + default: "amazon/appmesh-controller" |
| 11 | + required: false |
| 12 | + image_tag: |
| 13 | + description: "Root tag of the image to pull and push" |
| 14 | + required: true |
| 15 | + region: |
| 16 | + description: "AWS region to push images to" |
| 17 | + required: true |
| 18 | + dst_host: |
| 19 | + description: "URL of the target ECR repository to push images to" |
| 20 | + required: true |
| 21 | + dst_image_name: |
| 22 | + description: "Name of the destination image" |
| 23 | + default: "amazon/appmesh-controller" |
| 24 | + required: false |
| 25 | + role: |
| 26 | + description: "IAM role to assume to perform the deploys" |
| 27 | + required: true |
| 28 | + |
| 29 | +runs: |
| 30 | + using: "composite" |
| 31 | + steps: |
| 32 | + - name: Configure AWS Credentials For Region |
| 33 | + uses: aws-actions/configure-aws-credentials@v2 |
| 34 | + with: |
| 35 | + aws-region: "${{ inputs.region }}" |
| 36 | + role-to-assume: "${{ inputs.role }}" |
| 37 | + role-session-name: RegionalImageDeploy |
| 38 | + env: |
| 39 | + AWS_DEFAULT_REGION: "" |
| 40 | + AWS_REGION: "" |
| 41 | + AWS_ACCESS_KEY_ID: "" |
| 42 | + AWS_SECRET_ACCESS_KEY: "" |
| 43 | + AWS_SESSION_TOKEN: "" |
| 44 | + |
| 45 | + - name: Push Images To Region |
| 46 | + shell: bash |
| 47 | + env: |
| 48 | + SRC: "${{ inputs.src_host }}/${{ inputs.src_image_name }}:${{ inputs.image_tag }}" |
| 49 | + DST: "${{ inputs.dst_host }}/${{ inputs.dst_image_name }}:${{ inputs.image_tag }}" |
| 50 | + run: | |
| 51 | + if [[ "${{ inputs.dst_host }}" =~ "public.ecr.aws" ]]; then |
| 52 | + aws ecr-public get-login-password --region "us-east-1" | \ |
| 53 | + docker login --username AWS --password-stdin "public.ecr.aws" |
| 54 | + else |
| 55 | + aws ecr get-login-password --region "${{ inputs.region }}" | \ |
| 56 | + docker login --username AWS --password-stdin "${{ inputs.dst_host }}" |
| 57 | + fi |
| 58 | + docker tag "${SRC}-linux_amd64" "${DST}-linux_amd64" |
| 59 | + docker push "${DST}-linux_amd64" |
| 60 | + docker tag "${SRC}-linux_arm64" "${DST}-linux_arm64" |
| 61 | + docker push "${DST}-linux_arm64" |
| 62 | + docker manifest create "$DST" "${DST}-linux_amd64" "${DST}-linux_arm64" |
| 63 | + docker manifest push "$DST" |
0 commit comments