Updating ref to ECR for docker image #3
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
# Run tests and deploy to QA and Production on `nypl-digital-dev` account | |
name: CI | |
on: push | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
env: | |
CI: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Cache and install node modules | |
uses: bahmutov/npm-install@v1 | |
with: | |
install-command: npm install --ignore-script | |
- name: Test | |
run: npm run test | |
publish_qa: | |
needs: test | |
# TODO: update this to `qa` branch | |
if: github.ref == 'refs/heads/TGR-50/remediation-update' | |
name: Publish image to ECR and update ECS stack | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::946183545209: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: discovery-ui | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:qa-latest | |
- name: Force ECS Update | |
# Deploy to both the production and train clusters | |
run: | | |
aws ecs update-service --cluster nypl-discovery-qa-tf --service nypl-discovery-qa-tf --force-new-deployment | |
aws ecs update-service --cluster nypl-discovery-train-tf --service nypl-discovery-train-tf --force-new-deployment | |
publish_production: | |
needs: test | |
# TODO UPDATE THIS | |
if: github.ref == 'refs/heads/tgr-production' | |
name: Publish image to ECR and update ECS stack | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
with: | |
role-to-assume: arn:aws:iam::946183545209: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: discovery-ui | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:production-latest | |
- name: Force ECS Update | |
run: | | |
aws ecs update-service --cluster nypl-discovery-production-tf --service nypl-discovery-production-tf --force-new-deployment |