Merge pull request #55 from torusresearch/develop #18
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
# This workflow will build and push a new container image to Amazon ECR | |
# | |
# To use this workflow, you will need to complete the following set-up steps: | |
# | |
# 1. Create an ECR repository to store your images. | |
# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`. | |
# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name. | |
# Replace the value of `aws-region` in the workflow below with your repository's region. | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [master] | |
name: Prod release | |
jobs: | |
test: | |
name: run tests | |
strategy: | |
matrix: | |
node: ["20.x"] | |
os: [ubuntu-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: "npm" | |
- name: Run tests | |
run: npm run test:ci | |
deployToUS: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION_US }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: torus-metadata | |
IMAGE_TAG: latest | |
run: | | |
# Build a docker container and push it to ECR | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA . | |
echo "Pushing image to ECR..." | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA" | |
- name: Deploy | |
run: | | |
aws ecs update-service --cluster $ECS_CLUSTER_METADATA --service $ECS_SERVICE_METADATA --force-new-deployment | |
env: | |
ECS_CLUSTER_METADATA: prod-microservices | |
ECS_SERVICE_METADATA: torus-metadata-service | |
deployToSing: | |
name: Deploy | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION_SING }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: torus-metadata | |
IMAGE_TAG: latest | |
run: | | |
# Build a docker container and push it to ECR | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA . | |
echo "Pushing image to ECR..." | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$GITHUB_SHA" | |
- name: Deploy | |
run: | | |
aws ecs update-service --cluster $ECS_CLUSTER_METADATA --service $ECS_SERVICE_METADATA --force-new-deployment | |
env: | |
ECS_CLUSTER_METADATA: prod-microservices | |
ECS_SERVICE_METADATA: torus-metadata-service |