Skip to content

Merge pull request #235 from NYPL/dockerize #18

Merge pull request #235 from NYPL/dockerize

Merge pull request #235 from NYPL/dockerize #18

Workflow file for this run

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
- name: Test
run: npm run test
check_qa_tag:
name: Check if the release is tagged as QA
runs-on: ubuntu-latest
outputs:
has_qa_tag: ${{ steps.check-qa-tag.outputs.run_jobs }}
steps:
- name: check qa tag ${{ github.ref }}
id: check-qa-tag
run: |
if [[ ${{ github.ref }} =~ refs\/tags\/qa ]]; then
echo "run_jobs=true" >> $GITHUB_OUTPUT
else
echo "run_jobs=false" >> $GITHUB_OUTPUT
fi
publish_qa:
needs: [ check_qa_tag, test ]
if: needs.check_qa_tag.outputs.has_qa_tag == 'true'
name: Publish image to ECR and update ECS stack
runs-on: ubuntu-latest
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: nypl-library-card-app
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $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
run: |
aws ecs update-service --cluster nypl-library-card-app-qa --service nypl-library-card-app-qa --force-new-deployment