Skip to content

Commit

Permalink
Optimize base image acquisition on main
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti committed Feb 3, 2023
1 parent 13651d6 commit 88d6455
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,50 +19,51 @@ env:
ecr_repository: public.ecr.aws/w0m4q9l7/github-awslabs-smithy-rs-ci

jobs:
# Rebuild and upload the Docker build image
rebuild-docker-build-image:
# Build and upload the Docker build image if necessary
acquire-base-image:
runs-on: smithy_ubuntu-latest_8-core
name: Rebuild image
name: Acquire Base Image
outputs:
docker-login-password: ${{ steps.set-token.outputs.docker-login-password }}
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build image
run: |
IMAGE_TAG="$(./.github/scripts/docker-image-hash)"
cd tools/ci-build
docker build \
-t "${{ env.ecr_repository }}:${IMAGE_TAG}" \
-t "${{ env.ecr_repository }}:main" \
.
- name: Acquire credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ secrets.SMITHY_RS_PUBLIC_ECR_PUSH_ROLE_ARN }}
role-session-name: GitHubActions
aws-region: us-west-2
- name: Upload image
run: |
IMAGE_TAG="$(./.github/scripts/docker-image-hash)"
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
docker push "${{ env.ecr_repository }}:${IMAGE_TAG}"
docker push "${{ env.ecr_repository }}:main"
- name: Save the docker login password to the output
id: set-token
run: |
ENCRYPTED_PAYLOAD=$(
gpg --symmetric --batch --passphrase "${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }}" --output - <(aws ecr-public get-login-password --region us-east-1) | base64 -w0
)
echo "docker-login-password=$ENCRYPTED_PAYLOAD" >> $GITHUB_OUTPUT
- name: Acquire base image
id: acquire
env:
DOCKER_BUILDKIT: 1
ENCRYPTED_DOCKER_PASSWORD: ${{ steps.set-token.outputs.docker-login-password }}
DOCKER_LOGIN_TOKEN_PASSPHRASE: ${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }}
run: ./.github/scripts/acquire-build-image
- name: Tag and upload image
run: |
IMAGE_TAG="$(./.github/scripts/docker-image-hash)"
docker tag "${{ env.ecr_repository }}:${IMAGE_TAG}" "${{ env.ecr_repository }}:main"
docker push "${{ env.ecr_repository }}:${IMAGE_TAG}"
docker push "${{ env.ecr_repository }}:main"
# Run the shared CI after a Docker build image has been uploaded to ECR
ci:
needs: rebuild-docker-build-image
needs: acquire-base-image
uses: ./.github/workflows/ci.yml
with:
run_sdk_examples: true
secrets:
ENCRYPTED_DOCKER_PASSWORD: ${{ needs.rebuild-docker-build-image.outputs.docker-login-password }}
ENCRYPTED_DOCKER_PASSWORD: ${{ needs.acquire-base-image.outputs.docker-login-password }}
DOCKER_LOGIN_TOKEN_PASSPHRASE: ${{ secrets.DOCKER_LOGIN_TOKEN_PASSPHRASE }}

0 comments on commit 88d6455

Please sign in to comment.