a working version 2.1 #55
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On merge into the `dev` branch, build the image and deploy to ECR. | |
# This is in the `nypl-dev` account. | |
name: Publish dev | |
on: | |
push: | |
branches: [dev] | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
publish_qa: | |
name: Publish image to ECR and update ECS stack | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::491147561046:role/GithubActionsDeployerRole | |
aws-region: us-east-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Build, tag, and push image to Amazon ECR | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: ppd | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
aws s3 cp s3://ppd-dev-db/ppd.db . --no-progress | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
#MANIFEST=$(aws ecr batch-get-image --repository-name $ECR_REPOSITORY --image-ids imageTag="dev-latest" --output json | jq --raw-output --join-output '.images[0].imageManifest') | |
#aws ecr batch-delete-image --repository-name $ECR_REPOSITORY --image-ids imageTag="dev-previous" || true | |
#aws ecr put-image --repository-name $ECR_REPOSITORY --image-tag "dev-previous" --image-manifest "$MANIFEST" | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:dev-latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev-latest | |
- name: Force ECS Update | |
run: | | |
aws ecs update-service --cluster ppd-dev --service ppd-dev --force-new-deployment |