Skip to content

Merge pull request #700 from avrae/AVR-542 #137

Merge pull request #700 from avrae/AVR-542

Merge pull request #700 from avrae/AVR-542 #137

name: Deploy Staging
on:
release:
types: [published]
push:
branches:
- dev
- master
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 14
uses: actions/setup-node@v4
with:
node-version: "14"
cache: "npm"
- name: Install deps
run: |
npm install
npm run build-themes
- name: Update Chrome
run: |
sudo apt-get update
sudo apt-get --only-upgrade install google-chrome-stable
google-chrome --version
- name: Run E2E Tests
run: |
npm run e2e:stg
- name: Build SSR
run: |
npm run build-prod:ssr
cp dist/frontend/browser/index.html dist/frontend/browser/404.html
- name: Upload dist artifact
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error
deploy:
runs-on: ubuntu-latest
needs: build
env:
CLUSTER_NAME: avrae
SERVICE_NAME: avrae-io
DEPLOY_ENV: stg
REGION: us-east-2
steps:
- uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AVRAE_GITHUB_OIDC_ROLE_ARN }}
role-session-name: "avrae-io-deploy-stg"
aws-region: ${{ env.REGION }}
- 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: avrae/${{ env.SERVICE_NAME }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $SERVICE_NAME .
docker tag $SERVICE_NAME $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker tag $SERVICE_NAME $ECR_REGISTRY/$ECR_REPOSITORY:$DEPLOY_ENV
docker tag $SERVICE_NAME $ECR_REGISTRY/$ECR_REPOSITORY:live
docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
- name: Deploy Amazon ECS task definition
run: |
aws ecs update-service --cluster $CLUSTER_NAME-$DEPLOY_ENV --service $SERVICE_NAME --force-new-deployment --region $REGION