Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:

- name: Sync files to S3
run: |
aws s3 sync frontend/dist s3://warren-center-stage.npts.tech --acl public-read --follow-symlinks --delete
aws s3 sync frontend/dist s3://warren-center.npts.tech --acl public-read --follow-symlinks --delete
aws cloudfront create-invalidation --distribution-id ET4378B6T78I9 --paths "/*"

build-and-deploy-backend:
Expand Down Expand Up @@ -79,29 +79,9 @@ jobs:
REPOSITORY: wc-repo
IMAGE_TAG: ${{ github.sha}}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker build -t $ECR_REGISTRY/$REPOSITORY:latest .
docker push $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$REPOSITORY:latest
echo "image=$ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "image=$ECR_REGISTRY/$REPOSITORY:latest" >> $GITHUB_OUTPUT
- name: Bump Server
uses: appleboy/ssh-action@v0.1.4
with:
script: |
export NVM_DIR=~/.nvm
export PATH=$PATH:~/.local/share/pnpm/:~/.nvm/versions/node/v18.16.1/bin/pnpm
source ~/.nvm/nvm.sh
alias npm=pnpm
cd Warren-Automated-Onboard/backend
npx prisma migrate deploy
cd ~
docker pull $ECR_REGISTRY/$REPOSITORY:latest
docker compose up -d nuxt --force-recreate
host: twc-gateway-stage-api.npts.tech
cipher: ssh-ed25519
username: ubuntu
key: ${{ secrets.STAGE }}
87 changes: 87 additions & 0 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI/CD Pipeline - Stage

on:
push:
branches:
- stage

jobs:
build-and-deploy-frontend:
permissions:
id-token: write # This is required for requesting the JWT
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: |
cd frontend
npm install

- name: Build frontend
run: |
cd frontend
npm run build
- name: configure aws credentials
id: creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::654654236858:role/GithubActions
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-2

- name: Sync files to S3
run: |
aws s3 sync frontend/dist s3://warren-center.npts.tech --acl public-read --follow-symlinks --delete
aws cloudfront create-invalidation --distribution-id ET4378B6T78I9 --paths "/*"

build-and-deploy-backend:
permissions:
id-token: write # This is required for requesting the JWT
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'

- name: Install dependencies
run: |
cd backend
npm install
npx prisma generate

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::654654236858:role/GithubActions
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

- name: Build and Push Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry}}
REPOSITORY: wc-repo
IMAGE_TAG: ${{ github.sha}}-stage
run: |
docker build -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker build -t $ECR_REGISTRY/$REPOSITORY:stage .
docker push $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$REPOSITORY:stage
echo "image=$ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "image=$ECR_REGISTRY/$REPOSITORY:stage" >> $GITHUB_OUTPUT