Skip to content

Update getting-started.mdx #1

Update getting-started.mdx

Update getting-started.mdx #1

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
concurrency: "only one deploy at a time"
env:
DATABASE_BRANCH_NAME: pre-release-tests
PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }}
PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }}
jobs:
test_api_worker:
name: Unit Test API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup pscale
uses: planetscale/setup-pscale-action@v1
with:
version: latest
- name: Create a branch
run: pscale branch create unkey $DATABASE_BRANCH_NAME --from=main --org=unkey --wait
- name: Create a password
id: database_password
run: |
res=$(pscale password create unkey $DATABASE_BRANCH_NAME password-name --role=admin --ttl=900 --debug --org=unkey --format=json)
# Extract secrets
database_host=$(echo $res | jq -r '.access_host_url')
database_username=$(echo $res | jq -r '.username')
database_password=$(echo $res | jq -r '.plain_text')
# Mask secrets
echo "::add-mask::$database_host"
echo "::add-mask::$database_username"
echo "::add-mask::$database_password"
# Set outputs
echo "DATABASE_HOST=$database_host" >> "$GITHUB_ENV"
echo "DATABASE_USERNAME=$database_username" >> "$GITHUB_ENV"
echo "DATABASE_PASSWORD=$database_password" >> "$GITHUB_ENV"
- name: Install
uses: ./.github/actions/install
- name: Test
run: bun test src/routes --coverage --timeout 10000 --rerun-each 3
working-directory: apps/api
env:
UNKEY_ROOT_KEY: "not-empty" # this is not requried for these tests, but it is required for the env validation, I should fix this
- name: Delete planetscale branch
if: always()
run: |
pscale branch delete unkey $DATABASE_BRANCH_NAME --force --org=unkey
preview:
environment: Preview
runs-on: ubuntu-latest
name: Preview
steps:
- uses: actions/checkout@v3
- uses: pnpm/[email protected]
with:
version: latest
- name: Install
uses: ./.github/actions/install
- name: Build
run: pnpm turbo run build --filter='./apps/api'
- name: Deploy
run: wrangler deploy --env=preview --var VERSION:${GITHUB_REF#refs/*/}
working-directory: apps/api
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
preview-tests:
environment: Preview
needs: preview
name: End to End Test Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install
uses: ./.github/actions/install
- name: Test
run: bun test src/integration --timeout 10000 --rerun-each 10
working-directory: apps/api
env:
UNKEY_BASE_URL: https://preview-api.unkey.dev
UNKEY_ROOT_KEY: ${{ secrets.PREVIEW_ROOT_KEY }}
canary:
needs:
- test_api_worker
- preview-tests
environment: Canary
runs-on: ubuntu-latest
name: Deploy Canary
steps:
- uses: actions/checkout@v3
- name: Install
uses: ./.github/actions/install
- name: Build
run: pnpm turbo run build --filter='./apps/api'
- name: Deploy
run: wrangler deploy --env=canary --var VERSION:${GITHUB_REF#refs/*/}
working-directory: apps/api
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
canary-tests:
environment: Canary
needs: canary
name: End to End Test Canary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install
uses: ./.github/actions/install
- name: Test
run: bun test src/integration --timeout 10000 --rerun-each 10
working-directory: apps/api
env:
UNKEY_BASE_URL: https://canary.unkey.dev
UNKEY_ROOT_KEY: ${{ secrets.CANARY_ROOT_KEY }}
production:
if: "!github.event.release.prerelease"
needs:
- canary
- canary-tests
environment: Production
runs-on: ubuntu-latest
name: Deploy Production
steps:
- uses: actions/checkout@v3
- name: Install
uses: ./.github/actions/install
- name: Build
run: pnpm turbo run build --filter='./apps/api'
- name: Deploy
run: wrangler deploy --env=production --var VERSION:${GITHUB_REF#refs/*/}
working-directory: apps/api
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}