chore(#137): yeet nx cloud and simplify deployment scripts #201
Workflow file for this run
This file contains hidden or 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: CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
actions: read | |
contents: read | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
outputs: | |
affected-projects: ${{ steps.record-affected-projects.outputs.affected-projects }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Dotenv | |
run: | | |
echo "${{ secrets.DOTENV_APP_WEB_DEV }}" > projects/app-web/.env.development.local | |
echo "${{ secrets.DOTENV_APP_WEB_E2E }}" > projects/app-web-e2e/.env | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.18.3 | |
cache: 'yarn' | |
- name: Install Dependencies | |
run: yarn install --immutable | |
- name: Track main branch | |
run: git branch --track main origin/main | |
if: ${{ github.event_name == 'pull_request' }} | |
- name: Setup Docker image cache | |
uses: ScribeMD/[email protected] | |
id: docker-cache | |
with: | |
key: docker-${{ runner.os }}-${{ github.sha }} | |
- name: Generate Types | |
run: yarn nx run app-web:typegen | |
- name: Generate Styles | |
run: yarn codegen:styles | |
- name: Check Formatting | |
run: yarn format --check | |
- name: Lint | |
run: yarn lint | |
- name: Unit Tests | |
run: | | |
yarn pg:test-container:start | |
yarn test | |
- name: Build | |
if: ${{ github.ref_name != 'main' }} | |
run: yarn nx affected -t build | |
- name: Install E2E browsers | |
run: yarn playwright install --with-deps --only-shell chromium | |
- name: E2E Tests | |
run: yarn nx affected -t e2e | |
- name: Upload Videos Of Failed E2E | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: playwright-results | |
include-hidden-files: true | |
path: projects/app-web-e2e/.test-results | |
- name: Record Affected Projects | |
id: record-affected-projects | |
if: ${{ github.ref_name == 'main' }} | |
run: | | |
delimiter="$(openssl rand -hex 8)" | |
echo "affected-projects<<${delimiter}" >> "${GITHUB_OUTPUT}" | |
yarn nx show projects --affected >> "${GITHUB_OUTPUT}" | |
echo "${delimiter}" >> "${GITHUB_OUTPUT}" | |
- name: Setup Fly CLI | |
if: ${{ github.ref_name == 'main' }} | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Create base Docker image | |
if: ${{ steps.docker-cache.outputs.cache-hit != 'true' }} && ${{ github.ref_name == 'main' }} | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: Dockerfile | |
tags: vers/monorepo-base:latest | |
push: false | |
- name: Deploy MongoDB | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'db-mongo') }} | |
run: yarn deploy:db-mongo --configuration=production | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
- name: Deploy Postgres Migrations | |
if: ${{ github.ref_name == 'main' && | |
(contains(steps.record-affected-projects.outputs.affected-projects, 'db-postgres') || | |
contains(steps.record-affected-projects.outputs.affected-projects, 'lib-postgres-schema')) }} | |
run: yarn deploy:db-postgres --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy API Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-api') }} | |
run: yarn deploy:service-api --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy Avatar Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-avatar') }} | |
run: yarn deploy:service-avatar --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy Email Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-email') }} | |
run: yarn deploy:service-email --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy Session Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-session') }} | |
run: yarn deploy:service-session --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy User Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-user') }} | |
run: yarn deploy:service-user --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy Verification Service | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'service-verification') }} | |
run: yarn deploy:service-verification --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
- name: Deploy Web App | |
if: ${{ github.ref_name == 'main' && contains(steps.record-affected-projects.outputs.affected-projects, 'app-web') }} | |
run: yarn deploy:app-web --configuration=production | |
env: | |
COMMIT_SHA: ${{ github.sha }} | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |