Skip to content

Commit

Permalink
Updated version of check_images_x_region & Tags Fix (#10)
Browse files Browse the repository at this point in the history
* Use updated version of check_images_x_region

And use tagged version of configure-aws-credentials

* Remove tag from push --all-tags

This used to work, but now gives an error. I guess it is funny
to say "all-tags" and then specify a tag.
  • Loading branch information
cameron-dunn-sublime authored Dec 23, 2021
1 parent f6f6fd3 commit e494fe6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
43 changes: 38 additions & 5 deletions .github/workflows/check_images_x_region.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set -e

tag=$1

timeout_seconds=120

# Use a variable because return 1 will exit the script with `set -e`, but we want to retry.
checkImageResult="false"

function checkImages() {
repo=$1
primary_sha=$(aws ecr describe-images --region us-east-1 --repository-name $repo --image-ids imageTag=$tag | jq -r '.imageDetails[0].imageDigest')
Expand All @@ -13,12 +18,40 @@ function checkImages() {

if [[ "$sha" != "$primary_sha" ]]; then
echo "Incomplete ECR propagation for repo $repo (tag $tag) in $region. Expected $primary_sha but found $sha."
exit 1
return 0
fi

echo "ECR propagation for repo $repo (tag $tag) in $region is complete. Found $sha"
done

checkImageResult="true"

return 0
}

function checkImagesWithTimeout() {
repo=$1

end=$((SECONDS+$timeout_seconds))

while [ $SECONDS -lt $end ]; do
checkImageResult="false"
checkImages $repo

if [ "$checkImageResult" = "true" ]; then
return 0
fi
echo "Replication has not finished for $repo, sleeping."
sleep 5
done

echo "Replication did not finish for $repo after waiting $timeout_seconds"

# Just exit instead of checking status codes below (although it doesn't matter with `set -e`
exit 1
}

checkImages strelka-frontend
checkImages strelka-backend
checkImages strelka-manager
checkImages strelka-mmrpc
checkImagesWithTimeout strelka-frontend
checkImagesWithTimeout strelka-backend
checkImagesWithTimeout strelka-manager
checkImagesWithTimeout strelka-mmrpc
2 changes: 1 addition & 1 deletion .github/workflows/release-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@036a4a1ddf2c0e7a782dca6e083c6c53e5d90321 # No released version with OIDC
uses: aws-actions/configure-aws-credentials@1.6
with:
# Use a role instead of including credentials in secrets, but still hide that role name to be gated by GH environments.
role-to-assume: ${{ secrets.ECR_REPO_ROLE }}
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/tag-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@036a4a1ddf2c0e7a782dca6e083c6c53e5d90321 # No released version with OIDC
uses: aws-actions/configure-aws-credentials@1.6
with:
# Use a role instead of including credentials in secrets, but still hide that role name to be gated by GH environments.
role-to-assume: ${{ secrets.ECR_REPO_ROLE }}
Expand Down Expand Up @@ -79,8 +79,8 @@ jobs:
docker tag $ECR_REGISTRY/strelka-frontend:$VERSION $ECR_REGISTRY/strelka-frontend:$MINOR_VERSION
docker tag $ECR_REGISTRY/strelka-frontend:$VERSION sublimesec/strelka-frontend:$MINOR_VERSION
docker push --all-tags $ECR_REGISTRY/strelka-frontend:latest
docker push --all-tags sublimesec/strelka-frontend:latest
docker push --all-tags $ECR_REGISTRY/strelka-frontend
docker push --all-tags sublimesec/strelka-frontend
- name: Pull, Tag, Push BackEnd
env:
Expand All @@ -100,8 +100,8 @@ jobs:
docker tag $ECR_REGISTRY/strelka-backend:$VERSION $ECR_REGISTRY/strelka-backend:$MINOR_VERSION
docker tag $ECR_REGISTRY/strelka-backend:$VERSION sublimesec/strelka-backend:$MINOR_VERSION
docker push --all-tags $ECR_REGISTRY/strelka-backend:latest
docker push --all-tags sublimesec/strelka-backend:latest
docker push --all-tags $ECR_REGISTRY/strelka-backend
docker push --all-tags sublimesec/strelka-backend
- name: Pull, Tag, Push Manager
env:
Expand All @@ -121,8 +121,8 @@ jobs:
docker tag $ECR_REGISTRY/strelka-manager:$VERSION $ECR_REGISTRY/strelka-manager:$MINOR_VERSION
docker tag $ECR_REGISTRY/strelka-manager:$VERSION sublimesec/strelka-manager:$MINOR_VERSION
docker push --all-tags $ECR_REGISTRY/strelka-manager:latest
docker push --all-tags sublimesec/strelka-manager:latest
docker push --all-tags $ECR_REGISTRY/strelka-manager
docker push --all-tags sublimesec/strelka-manager
- name: Pull, Tag, Push MMRPC
env:
Expand All @@ -142,8 +142,8 @@ jobs:
docker tag $ECR_REGISTRY/strelka-mmrpc:$VERSION $ECR_REGISTRY/strelka-mmrpc:$MINOR_VERSION
docker tag $ECR_REGISTRY/strelka-mmrpc:$VERSION sublimesec/strelka-mmrpc:$MINOR_VERSION
docker push --all-tags $ECR_REGISTRY/strelka-mmrpc:latest
docker push --all-tags sublimesec/strelka-mmrpc:latest
docker push --all-tags $ECR_REGISTRY/strelka-mmrpc
docker push --all-tags sublimesec/strelka-mmrpc
- name: Validate All X-Region Replication
run: |
Expand Down

0 comments on commit e494fe6

Please sign in to comment.