Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/github-actions' into github-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal Ngai committed Mar 9, 2021
2 parents 5ab7a2c + a73e267 commit e7bc156
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions .github/workflows/build-qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,52 @@
# build a container and deploy to ECR
name: Publish qa
on:
pull_request:
branches: [fc-components]
types: [pull_request]
push:
branches:
- github-actions
# pull_request:
# branches: [fc-components]
# types: [closed]

jobs:
publish_qa:
name: Publish image to ECR
if: github.event.pull_request.merged
name: Publish image to ECR
# Temporarily removing this line for testing purposes
# if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- name: checkout
- uses: actions/checkout@v2
uses: actions/checkout@v2

- id: nvmrc
- id: nvmrc
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)

- uses: actions/setup-node@v2
- name: Set up node with version from nvm
uses: actions/setup-node@v2
with: { node-version: "${{ steps.nvmrc.outputs.NODE_VERSION }}" }

- run: npm install
- run: npm build

- name: Configure AWS credentials from Test account
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- 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: sfr-front-end
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:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: sfr-front-end
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:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Force ECS Update
run: |
aws ecs update-service --cluster sfr-front-end-qa --service sfr-front-end-qa --force-new-deployment
- name: Force ECS Update
run: |
aws ecs update-service --cluster sfr-front-end-qa --service sfr-front-end-qa --force-new-deployment

0 comments on commit e7bc156

Please sign in to comment.