wip: footerOmega -d #825
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: DEPLOY | |
on: | |
push: | |
branches: | |
- dev | |
workflow_dispatch: | |
inputs: | |
cmd: | |
description: Command | |
required: true | |
type: choice | |
options: | |
- deploy | |
- test | |
tags: | |
description: Tags | |
required: false | |
type: string | |
# if deploy on release | |
# release: | |
# types: [published] | |
# needed for github/git auth | |
permissions: | |
contents: write | |
issues: write # Only add other permissions if necessary for your workflow | |
env: | |
CI: true | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
APOLLO_API_KEY: ${{ secrets.APOLLO_API_KEY }} | |
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_ACCESS_KEY_SECRET: ${{ secrets.AWS_ACCESS_KEY_SECRET }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
AWS_BUCKET_MEDIA: ${{ secrets.AWS_BUCKET_MEDIA }} | |
REDIS_URL: ${{ secrets.REDIS_URL }} | |
CLICKHOUSE_URL: ${{ secrets.CLICKHOUSE_URL }} | |
STRIPE_SECRET_KEY_TEST: ${{ secrets.STRIPE_SECRET_KEY_TEST }} | |
TOKEN_SECRET: ${{ secrets.TOKEN_SECRET }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
SMTP_HOST: ${{ secrets.SMTP_HOST }} | |
SMTP_USER: ${{ secrets.SMTP_USER }} | |
SMTP_PASSWORD: ${{ secrets.SMTP_PASSWORD }} | |
UNSPLASH_ACCESS_KEY: ${{ secrets.UNSPLASH_ACCESS_KEY }} | |
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SHOULD_DEPLOY: ${{ contains(github.event.head_commit.message, '-d') }} | |
SHOULD_RELEASE: ${{ contains(github.event.head_commit.message, '-r') }} | |
BETTER_STACK_SOURCE_TOKEN: ${{ secrets.BETTER_STACK_SOURCE_TOKEN }} | |
jobs: | |
test: | |
if: 'contains(github.event.head_commit.message, ''skip'') == false' | |
env: | |
REDIS_URL: redis://localhost:6379 | |
CLICKHOUSE_URL: http://default:@localhost:8123 | |
POSTGRES_URL: http://test:test@localhost:5432/test | |
name: build and test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get The Code | |
uses: actions/checkout@v4 | |
- name: List files in workspace | |
run: ls -alh ${{ github.workspace }} | |
- name: List files in workspace | |
run: ls -alh /home/runner/work/_temp | |
# - name: Install Vector for Better Stack | |
# run: | | |
# curl -sSL https://logs.betterstack.com/setup-vector/ubuntu/${{ secrets.BETTER_STACK_SOURCE_TOKEN }} \ | |
# -o /tmp/setup-vector.sh && \ | |
# bash /tmp/setup-vector.sh | |
# - name: Configure Vector with custom configuration | |
# run: | | |
# sudo envsubst < "${{ github.workspace }}/.github/workflows/vector.toml" | sudo tee /etc/vector/vector.toml > /dev/null | |
# sudo systemctl restart vector | |
# echo "Configuration complete." | |
# sudo systemctl restart vector | |
# echo "Vector service restarted." | |
# env: | |
# BETTER_STACK_SOURCE_TOKEN: ${{ secrets.BETTER_STACK_SOURCE_TOKEN }} | |
- name: Debug Info | |
run: | | |
echo "SHOULD_RELEASE: ${{ env.SHOULD_RELEASE }}" | |
echo "SHOULD_DEPLOY: ${{ env.SHOULD_DEPLOY }}" | |
echo "Commit Message: ${{ github.event.head_commit.message }}" | |
- name: Get current time | |
id: current_time | |
run: echo "time=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Write Build Information to a Config File | |
run: | | |
echo '{ | |
"commitId": "${{ github.sha }}", | |
"buildTime": "${{ steps.current_time.outputs.time }}", | |
"buildNumber": "${{ github.run_number }}", | |
"branch": "${{ github.ref_name }}" | |
}' > ./buildInfo.json | |
shell: bash | |
- name: Set up DNS for subdomain testing | |
run: | | |
echo "127.0.0.1 test.lan.com" | sudo tee -a /etc/hosts | |
- name: Test DNS resolution | |
run: | | |
echo "Testing DNS resolution for lan.com and its subdomains..." | |
dig +short test.lan.com @127.0.0.1 || echo "Failed to resolve test.lan.com" | |
- name: Configure Git | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "[email protected]" | |
- name: Install GH CLI | |
run: | | |
sudo apt update | |
sudo apt install -y gh | |
- name: Install pnpm | |
uses: pnpm/action-setup@v4 | |
with: | |
version: 9.6.0 | |
- name: Set Node Version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.5.1 | |
cache: pnpm | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install FlyCtl CLI | |
uses: superfly/flyctl-actions/setup-flyctl@master | |
- name: Install Deps | |
run: pnpm -v && pnpm i && pnpm rebuild --recursive | |
- name: Run Type Check | |
run: npm run types:ci | |
# - name: Restore ESLint cache | |
# uses: actions/cache/restore@v4 | |
# id: eslint-cache-restore | |
# with: | |
# path: .eslintcache | |
# key: ${{ runner.os }}-eslint-${{ github.ref }} | |
# restore-keys: | | |
# ${{ runner.os }}-eslint- | |
# - name: Run ESLint | |
# run: npm run lint:dev | |
# continue-on-error: false | |
# - name: Save ESLint cache | |
# uses: actions/cache/save@v4 | |
# if: always() | |
# with: | |
# path: .eslintcache | |
# key: ${{ runner.os }}-eslint-${{ github.ref }}-${{ github.sha }} | |
- name: Debug Git Config | |
run: | | |
git config --list | |
git remote -v | |
- name: Install Playwright Browsers | |
run: npx playwright install | |
- name: Run Docker Compose (DB) | |
run: docker compose -f ./docker/docker-compose.yml pull && docker compose -f ./docker/docker-compose.yml up --build -d | |
- name: Create Tables | |
run: npm -w @fiction/www exec -- fiction run generate | |
- name: DEBUG tests | |
run: npm exec -- vitest run debug -u --passWithNoTests | |
- name: AI tests | |
run: npm exec -- vitest run aix -u --passWithNoTests | |
- name: ENVIRONMENT tests | |
run: npm exec -- vitest run envi -u --passWithNoTests | |
- name: BUILD tests | |
env: | |
NODE_OPTIONS: --max_old_space_size=4096 | |
run: npm exec -- vitest run build -u --no-file-parallelism | |
- name: SPOT tests | |
run: npm exec -- vitest run spot -u --passWithNoTests | |
- name: FLOW tests | |
run: npm exec -- vitest run flow -u --no-file-parallelism --passWithNoTests | |
- name: E2E/UI tests | |
run: npm exec -- vitest run uiux -u --no-file-parallelism | |
- name: UNIT tests | |
run: npm exec -- vitest run unit -u | |
- name: Install Build Packages | |
if: env.SHOULD_DEPLOY == 'true' | |
run: pnpm add tsup cross-env --global | |
- name: Build Bundles | |
if: env.SHOULD_DEPLOY == 'true' | |
run: npm exec -- fiction run bundle | |
- name: Render Apps | |
if: env.SHOULD_DEPLOY == 'true' | |
run: npm exec -- fiction run render | |
- name: DIST unit tests | |
if: env.SHOULD_DEPLOY == 'true' | |
run: npm exec -- vitest run dist -u | |
- name: Deploy Apps | |
if: env.SHOULD_DEPLOY == 'true' | |
run: | | |
cross-env DOMAIN=fiction APP=beacon npm run deploy | |
cross-env DOMAIN=fiction APP=www npm run deploy | |
cross-env DOMAIN=fiction APP=sites npm run deploy | |
- name: Release Code | |
if: env.SHOULD_RELEASE == 'true' | |
run: | | |
npm run i:lockfile && npm run release | |
- name: Post Notification | |
if: failure() | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
# This data can be any valid JSON from a previous step in the GitHub Action | |
payload: | | |
{ | |
"icon_emoji": "${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}", | |
"username": "supereon", | |
"channel": "#notify", | |
"text": "Workflow *${{ github.workflow }}* on *${{ github.ref }}* (commit: ${{ github.sha }}) completed with status: *${{ job.status }}*. <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |