Skip to content

Commit

Permalink
Add APP_ENV variable
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Sep 10, 2024
1 parent 159eb5b commit dbebd90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/deploy_production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:
env:
AWS_DEFAULT_REGION: us-east-1
LOCAL_TAG_NAME: research-catalog:${{ github.ref_name }}-${{ github.run_number }}
APP_ENV: production

jobs:
deploy:
Expand All @@ -33,13 +34,15 @@ jobs:

- name: Build and push Docker image to Amazon ECR
env:
NEXT_PUBLIC_APP_ENV: production
ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog:production-latest
ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog:$APP_ENV-latest
MANIFEST: $(aws ecr batch-get-image --repository-name research-catalog --image-ids imageTag="$APP_ENV-latest" --output json | jq --raw-output --join-output '.images[0].imageManifest')
run: |
docker build --build-arg NEXT_PUBLIC_APP_ENV=$NEXT_PUBLIC_APP_ENV --tag $LOCAL_TAG_NAME .
docker build --build-arg NEXT_PUBLIC_APP_ENV=$APP_ENV --tag $LOCAL_TAG_NAME .
docker tag $LOCAL_TAG_NAME $ECR_URL
aws ecr batch-delete-image --repository-name research-catalog --image-ids imageTag="$APP_ENV-previous" || true
aws ecr put-image --repository-name research-catalog --image-tag "$APP_ENV-previous" --image-manifest "$MANIFEST" || true
docker push $ECR_URL
- name: Update ECS service
run: |
aws ecs update-service --cluster research-catalog-production --service research-catalog-production --force-new-deployment
aws ecs update-service --cluster research-catalog-$APP_ENV --service research-catalog-$APP_ENV --force-new-deployment
12 changes: 8 additions & 4 deletions .github/workflows/deploy_qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ permissions:
env:
AWS_DEFAULT_REGION: us-east-1
LOCAL_TAG_NAME: research-catalog:${{ github.ref_name }}-${{ github.run_number }}
APP_ENV: qa

jobs:
deploy:
Expand All @@ -34,13 +35,16 @@ jobs:

- name: Build and push Docker image to Amazon ECR
env:
NEXT_PUBLIC_APP_ENV: qa
ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog:$NEXT_PUBLIC_APP_ENV-latest
ECR_URL: 946183545209.dkr.ecr.us-east-1.amazonaws.com/research-catalog:$APP_ENV-latest
MANIFEST: $(aws ecr batch-get-image --repository-name research-catalog --image-ids imageTag="$APP_ENV-latest" --output json | jq --raw-output --join-output '.images[0].imageManifest')

run: |
docker build --build-arg NEXT_PUBLIC_APP_ENV=$NEXT_PUBLIC_APP_ENV --tag $LOCAL_TAG_NAME .
docker build --build-arg NEXT_PUBLIC_APP_ENV=$APP_ENV --tag $LOCAL_TAG_NAME .
docker tag $LOCAL_TAG_NAME $ECR_URL
aws ecr batch-delete-image --repository-name research-catalog --image-ids imageTag="$APP_ENV-previous" || true
aws ecr put-image --repository-name research-catalog --image-tag "$APP_ENV-previous" --image-manifest "$MANIFEST" || true
# docker push $ECR_URL
# - name: Update ECS service
# run: |
# aws ecs update-service --cluster research-catalog-qa --service research-catalog-qa --force-new-deployment
# aws ecs update-service --cluster research-catalog-$APP_ENV --service research-catalog-$APP_ENV --force-new-deployment

0 comments on commit dbebd90

Please sign in to comment.