[MAPA-444] Inicializar o Prisma para salvar feedback #257
Workflow file for this run
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
name: Tests, Static Analysis and Deploy | |
env: | |
IANA_STG_DOMAIN: iana-chatbot.staging.bonde.org | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- 'main' | |
jobs: | |
integration: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Run tests | |
run: pnpm run test:ci | |
- name: Build | |
run: pnpm run build | |
ui-deployment: | |
runs-on: ubuntu-latest | |
needs: | |
- integration | |
if: always() && needs.integration.result == 'success' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: | | |
env="preview" | |
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then | |
env="production" | |
fi | |
cd packages/ui && vercel pull --yes --environment=$env --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
run: | | |
args="" | |
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then | |
args="--prod" | |
fi | |
cd packages/ui && vercel deploy $args --token=${{ secrets.VERCEL_TOKEN }} > domain.txt | |
if [[ ${GITHUB_REF} != "refs/heads/main" ]]; then | |
vercel alias --token=${{ secrets.VERCEL_TOKEN }} set `cat domain.txt` $IANA_STG_DOMAIN | |
fi | |
api-deployment: | |
runs-on: ubuntu-latest | |
needs: | |
- integration | |
if: always() && needs.integration.result == 'success' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Create env file | |
run: | | |
cat << EOF > .env | |
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} | |
AWS_S3_BUCKET=${{ secrets.AWS_S3_BUCKET }} | |
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION=${{ secrets.AWS_REGION }} | |
AWS_S3_BUCKET_NAME=${{ secrets.AWS_S3_BUCKET_NAME }} | |
NODE_ENV="production" | |
NEW_RELIC_ACCOUNT_ID=${{ secrets.NEW_RELIC_ACCOUNT_ID }} | |
NEW_RELIC_API_KEY=${{ secrets.NEW_RELIC_API_KEY }} | |
EOF | |
- name: Copy .env file to api package | |
run: find packages/api -type d -exec cp .env {} \; | |
- name: Install serverless globally | |
run: pnpm add serverless@3.38.0 --global | |
- name: Serverless AWS authentication | |
run: sls config credentials --provider aws --key ${{ secrets.AWS_ACCESS_KEY_ID }} --secret ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Deploy API | |
run: | | |
args="" | |
if [[ ${GITHUB_REF} == "refs/heads/main" ]]; then | |
args="--stage production" | |
fi | |
pnpm --filter api run deploy $args |