Skip to content

Usman/tidbits collection #539

Usman/tidbits collection

Usman/tidbits collection #539

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint_and_prettier:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max-old-space-size=8182
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: ~/.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run ESLint
run: yarn lint
- name: Run Prettier
run: yarn prettier-check
- name: Generate GraphQL Types
run: yarn graphql:generate
- name: Generate Prisma Client
run: yarn prisma:generate
- name: Run Compiler
run: yarn tsc
build_and_push_docker:
needs: lint_and_prettier
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
AWS_REGION: us-east-1 # Change this to the AWS region where your ECR repository is located
ECR_REPOSITORY: v2-api # Replace this with your ECR repository name
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 18
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: ~/.yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Configure AWS credentials
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: Install dependencies
run: yarn install --frozen-lockfile
- 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: v2-api
IMAGE_TAG: ${{ github.sha }}
run: |
aws sts get-caller-identity
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: Trigger ECS Deployment
env:
AWS_REGION: us-east-1
CLUSTER_NAME: v2-api-prod # Replace with your ECS cluster name
SERVICE_NAME: v2-api-prod-app # Replace with your ECS service name
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment