diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml new file mode 100644 index 000000000..8cd944667 --- /dev/null +++ b/.github/actions/deploy/action.yml @@ -0,0 +1,58 @@ +name: Deploy +description: "Deploy the project to Vercel and Supabase." +inputs: + vercel-token: + description: "The Vercel token to use for deployment." + required: true + vercel-org-id: + description: "The Vercel organization ID to use for deployment." + required: true + vercel-project-id: + description: "The Vercel project ID to use for deployment." + required: true + production: + description: "Whether to deploy to the production environment." + required: false + default: "false" + supabase-project-id: + description: "The Supabase project ID to use for deployment." + required: true + supabase-access-token: + description: "The Supabase access token to use for deployment." + required: true + supabase-db-password: + description: "The Supabase database password to use for deployment." + required: true +runs: + using: "composite" + steps: + - name: Setup Environment + uses: ./.github/actions/setup-env + with: + yarn-install: false + env: + YARN_ENABLE_HARDENED_MODE: "0" + - name: Supabase Deploy + id: deploy + uses: ./.github/actions/supabase-deploy + with: + supabase-project-id: ${{ inputs.supabase-project-id }} + supabase-access-token: ${{ inputs.supabase-access-token }} + supabase-db-password: ${{ inputs.supabase-db-password }} + - name: Extract Branch + id: extract-branch + uses: ./.github/actions/extract-branch + - name: Public Hostname + shell: bash + id: public-hostname + run: echo "public-hostname=sendapp-${{steps.extract-branch.outputs.branch}}-0xsend.vercel.app" >> $GITHUB_OUTPUT + - name: Vercel Deploy + uses: ./.github/actions/vercel-deploy + with: + vercel-token: ${{ inputs.vercel-token }} + vercel-org-id: ${{ inputs.vercel-org-id }} + vercel-project-id: ${{ inputs.vercel-project-id }} + public-hostname: ${{ steps.public-hostname.outputs.public-hostname }} + production: ${{ inputs.production }} + env: + YARN_ENABLE_HARDENED_MODE: "0" diff --git a/.github/actions/extract-branch/action.yml b/.github/actions/extract-branch/action.yml new file mode 100644 index 000000000..8774a7381 --- /dev/null +++ b/.github/actions/extract-branch/action.yml @@ -0,0 +1,21 @@ +name: "Extract Branch Name" +description: "Extract the branch name from the GitHub event payload and set it as an output cleaned for use in Vercel." +outputs: + branch: + description: "The cleaned branch name." + value: ${{ steps.extract.outputs.branch }} +runs: + using: "composite" + steps: + - name: Extract Branch Name + id: extract + shell: bash + run: | + branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + branch="${branch//\//-}" # Replace / with - + branch="${branch//_/-}" # Replace _ with - + branch="${branch,,}" # Convert to lowercase + branch="${branch//[^a-z0-9-]/}" # Remove any character that is not a-z, 0-9, or - + branch="${branch%-}" # Remove trailing hyphen, if any + branch="${branch#-}" # Remove leading hyphen, if any + echo "branch=${branch}" >> $GITHUB_OUTPUT diff --git a/.github/actions/supabase-deploy/action.yml b/.github/actions/supabase-deploy/action.yml new file mode 100644 index 000000000..bb4fbdf59 --- /dev/null +++ b/.github/actions/supabase-deploy/action.yml @@ -0,0 +1,37 @@ +name: Supabase Deploy Migrations +description: "Deploy the project to Supabase. Run migrations against the database." +inputs: + supabase-project-id: + description: "The Supabase project ID to use for deployment." + required: true + supabase-access-token: + description: "The Supabase access token to use for deployment." + required: true + supabase-db-password: + description: "The Supabase database password to use for deployment." + required: true +runs: + using: "composite" + steps: + - name: Mask Supabase Access Token + shell: bash + run: echo "::add-mask::${{ inputs.supabase-access-token }}" + - name: Mask Supabase Database Password + shell: bash + run: echo "::add-mask::${{ inputs.supabase-db-password }}" + - name: Mask Supabase Project ID + shell: bash + run: echo "::add-mask::${{ inputs.supabase-project-id }}" + - uses: supabase/setup-cli@v1 + with: + version: latest + - shell: bash + run: supabase link --project-ref ${{ inputs.supabase-project-id }} + env: + SUPABASE_ACCESS_TOKEN: ${{ inputs.supabase-access-token }} + SUPABASE_DB_PASSWORD: ${{ inputs.supabase-db-password }} + - shell: bash + run: supabase db push + env: + SUPABASE_ACCESS_TOKEN: ${{ inputs.supabase-access-token }} + SUPABASE_DB_PASSWORD: ${{ inputs.supabase-db-password }} diff --git a/.github/actions/vercel-deploy/action.yml b/.github/actions/vercel-deploy/action.yml index bf57bcad7..91298d749 100644 --- a/.github/actions/vercel-deploy/action.yml +++ b/.github/actions/vercel-deploy/action.yml @@ -4,10 +4,20 @@ inputs: vercel-token: description: "The Vercel token to use for deployment." required: true + vercel-org-id: + description: "The Vercel organization ID to use for deployment." + required: true + vercel-project-id: + description: "The Vercel project ID to use for deployment." + required: true public-hostname: description: "The public hostname alias to use for the deployment." required: false default: "" + production: + description: "Whether to deploy to the production environment." + required: false + default: "false" outputs: deployment-url: description: "The URL of the deployment." @@ -21,22 +31,41 @@ runs: - name: Switch to Vercel Send team shell: bash run: bunx vercel --token=${{ inputs.vercel-token }} team switch 0xsend + env: + VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} + VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} - name: Pull Vercel Environment Information shell: bash run: bunx vercel --token=${{ inputs.vercel-token }} pull --yes --environment=preview + env: + VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} + VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} - name: Build Project Artifacts shell: bash run: bunx vercel --token=${{ inputs.vercel-token }} build + env: + VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} + VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} - name: Deploy Project Artifacts to Vercel id: deploy shell: bash run: | - bunx vercel --token=${{ inputs.vercel-token }} deploy --prebuilt > deployment-url.txt + if [[ ${{ inputs.production }} == "true" ]]; then + bunx vercel --token=${{ inputs.vercel-token }} deploy --prebuilt --prod > deployment-url.txt + else + bunx vercel --token=${{ inputs.vercel-token }} deploy --prebuilt > deployment-url.txt + fi echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT echo ::notice::Deployment URL: $(cat deployment-url.txt) + env: + VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} + VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} - name: Set Vercel Branch Alias if: ${{ inputs.public-hostname != '' }} shell: bash run: | bunx vercel --token=${{ inputs.vercel-token }} -S 0xsend alias set ${{ steps.deploy.outputs.deployment_url }} ${{ inputs.public-hostname }} echo ::notice::Vercel Alias URL https://${{ inputs.public-hostname }}/ + env: + VERCEL_ORG_ID: ${{ inputs.vercel-org-id }} + VERCEL_PROJECT_ID: ${{ inputs.vercel-project-id }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f8d427f4..aa386dbf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,8 @@ jobs: SKIP_YARN_POST_INSTALL: 1 ci: + # skip if on dev and main (but not PRS to dev or main) + if: ${{ !(contains(github.ref, 'dev') || contains(github.ref, 'main')) }} runs-on: ubuntu-latest needs: [cache-deps] env: @@ -92,10 +94,9 @@ jobs: path: packages/playwright/playwright-report/ retention-days: 30 - # @todo create supabase branch https://supabase.com/docs/reference/cli/supabase-branches-update vercel-deploy-preview: - # skip if on dev since it will be deployed with another workflow - if: github.ref != 'refs/heads/dev' && github.ref != 'refs/heads/main' + # **always** skip if on dev and main since it will be deployed with another workflow + if: ${{ !(contains(github.ref, 'dev') || contains(github.ref, 'main') || contains(github.head_ref, 'dev') || contains(github.head_ref, 'main')) }} runs-on: ubuntu-latest needs: [cache-deps] @@ -117,24 +118,17 @@ jobs: env: YARN_ENABLE_HARDENED_MODE: 0 - name: Extract branch name - id: extract_branch - shell: bash - run: | - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} - branch="${branch//\//-}" # Replace / with - - branch="${branch//_/-}" # Replace _ with - - branch="${branch,,}" # Convert to lowercase - branch="${branch//[^a-z0-9-]/}" # Remove any character that is not a-z, 0-9, or - - branch="${branch%-}" # Remove trailing hyphen, if any - branch="${branch#-}" # Remove leading hyphen, if any - echo "branch=${branch}" >> $GITHUB_OUTPUT - echo "public_hostname=sendapp-${branch}-0xsend.vercel.app" >> $GITHUB_OUTPUT + id: extract-branch + uses: ./.github/actions/extract-branch + - name: Set Public Hostname + id: public-hostname + run: echo "public-hostname=sendapp-${{steps.extract-branch.outputs.branch}}-0xsend.vercel.app" >> $GITHUB_OUTPUT - name: Vercel Deploy - id: deploy + id: vercel-deploy uses: ./.github/actions/vercel-deploy with: vercel-token: ${{ secrets.VERCEL_TOKEN }} - public-hostname: ${{ steps.extract_branch.outputs.public_hostname }} + public-hostname: ${{ steps.public-hostname.outputs.public-hostname }} env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} @@ -142,5 +136,17 @@ jobs: with: message-id: vercel-preview-url message: | - Vercel Unique URL: [${{ steps.deploy.outputs.deployment-url }}](${{ steps.deploy.outputs.deployment-url }}) - Vercel Preview URL: [${{ steps.extract_branch.outputs.public_hostname }}](https://${{ steps.extract_branch.outputs.public_hostname }}/) + Vercel Unique URL: [${{ steps.vercel-deploy.outputs.deployment-url }}](${{ steps.vercel-deploy.outputs.deployment-url }}) + Vercel Preview URL: [${{ steps.public-hostname.outputs.public-hostname }}](https://${{ steps.public-hostname.outputs.public-hostname }}/) + + deploy-staging: + if: github.ref == 'refs/heads/dev' + needs: [cache-deps] + uses: ./.github/workflows/deploy-staging.yml + secrets: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} + STAGING_SUPABASE_PROJECT_ID: ${{ secrets.STAGING_SUPABASE_PROJECT_ID }} + STAGING_SUPABASE_DB_PASSWORD: ${{ secrets.STAGING_SUPABASE_DB_PASSWORD }} diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 000000000..81d68abb8 --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -0,0 +1,45 @@ +name: Deploy Staging + +on: + workflow_dispatch: + workflow_call: + secrets: + VERCEL_TOKEN: + description: 'Vercel token' + required: true + VERCEL_PROJECT_ID: + description: 'Vercel project id' + required: true + VERCEL_ORG_ID: + description: 'Vercel org id' + required: true + SUPABASE_ACCESS_TOKEN: + description: 'Supabase access token' + required: true + STAGING_SUPABASE_PROJECT_ID: + description: 'Staging Supabase project id' + required: true + STAGING_SUPABASE_DB_PASSWORD: + description: 'Staging Supabase db password' + required: true + +concurrency: + group: ${{ github.workflow }} + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - name: Deploy + uses: ./.github/actions/deploy + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} + production: false + supabase-project-id: ${{ secrets.STAGING_SUPABASE_PROJECT_ID }} + supabase-access-token: ${{ secrets.SUPABASE_ACCESS_TOKEN }} + supabase-db-password: ${{ secrets.STAGING_SUPABASE_DB_PASSWORD }} diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml deleted file mode 100644 index 4531de91c..000000000 --- a/.github/workflows/staging.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Deploy Staging - -on: - push: - branches: - - dev - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }} - -jobs: - supabase-deploy: - runs-on: ubuntu-latest - - env: - SUPABASE_ACCESS_TOKEN: '' # ${{ secrets.SUPABASE_ACCESS_TOKEN }} - SUPABASE_DB_PASSWORD: '' # ${{ secrets.STAGING_DB_PASSWORD }} - SUPABASE_PROJECT_ID: '' # ${{ secrets.STAGING_PROJECT_ID }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - uses: supabase/setup-cli@v1 - with: - version: latest - - - run: echo todo # supabase link --project-ref $SUPABASE_PROJECT_ID - - run: echo todo # supabase db push - - vercel-deploy: - runs-on: ubuntu-latest - - env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version-file: .node-version - cache: 'yarn' - - uses: oven-sh/setup-bun@v1 - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly - - name: Install Vercel CLI - run: yarn global add vercel - - name: Switch to Vercel Send team - run: vercel --token=${{ secrets.VERCEL_TOKEN }} team switch 0xsend - - name: Pull Vercel Environment Information - run: vercel --token=${{ secrets.VERCEL_TOKEN }} pull --yes --environment=preview - - name: Build Project Artifacts - run: vercel --token=${{ secrets.VERCEL_TOKEN }} build - - name: Extract branch name - shell: bash - run: | - branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} - branch="${branch//\//-}" # Replace / with - - branch="${branch//_/-}" # Replace _ with - - branch="${branch,,}" # Convert to lowercase - branch="${branch//[^a-z0-9-]/}" # Remove any character that is not a-z, 0-9, or - - branch="${branch%-}" # Remove trailing hyphen, if any - branch="${branch#-}" # Remove leading hyphen, if any - echo "branch=${branch}" >> $GITHUB_OUTPUT - echo "public_url=https://sendapp-${BRANCH}-0xsend.vercel.app" >> $GITHUB_OUTPUT - id: extract_branch - - name: Deploy Project Artifacts to Vercel - id: deploy - run: | - vercel --token=${{ secrets.VERCEL_TOKEN }} deploy --prebuilt \ - --env=NEXT_PUBLIC_URL=${{ steps.extract_branch.outputs.public_url }} \ - > deployment-url.txt && \ - echo "deployment_url=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT - echo ::notice::Deployment URL: $(cat deployment-url.txt) - - name: Set Vercel alias - run: vercel --token=${{ secrets.VERCEL_TOKEN }} -S 0xsend alias set ${{ steps.deploy.outputs.deployment_url }} ${{ steps.extract_branch.outputs.public_url }} diff --git a/supabase/config.toml b/supabase/config.toml index 1e52ce1e8..aa9107d52 100644 --- a/supabase/config.toml +++ b/supabase/config.toml @@ -3,8 +3,9 @@ project_id = "send" [api] +enabled = true port = 54321 -schemas = ["public", "storage"] +schemas = ["public", "storage", "graphql_public"] extra_search_path = ["public", "extensions"] max_rows = 100 diff --git a/supabase/package.json b/supabase/package.json index 64c25db84..c7f5dcadd 100644 --- a/supabase/package.json +++ b/supabase/package.json @@ -24,7 +24,7 @@ }, "devDependencies": { "dotenv-cli": "^6.0.0", - "supabase": "^1.99.0", + "supabase": "1.145.4", "type-fest": "^4.3.1" } } diff --git a/yarn.lock b/yarn.lock index 228f7a7ba..71b26e896 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5631,7 +5631,7 @@ __metadata: resolution: "@my/supabase@workspace:supabase" dependencies: dotenv-cli: "npm:^6.0.0" - supabase: "npm:^1.99.0" + supabase: "npm:1.145.4" type-fest: "npm:^4.3.1" languageName: unknown linkType: soft @@ -12564,7 +12564,7 @@ __metadata: languageName: node linkType: hard -"bin-links@npm:^4.0.1": +"bin-links@npm:^4.0.3": version: 4.0.3 resolution: "bin-links@npm:4.0.3" dependencies: @@ -23556,7 +23556,7 @@ __metadata: languageName: node linkType: hard -"node-fetch@npm:^3.2.10, node-fetch@npm:^3.3.2": +"node-fetch@npm:^3.3.2": version: 3.3.2 resolution: "node-fetch@npm:3.3.2" dependencies: @@ -28751,17 +28751,17 @@ __metadata: languageName: node linkType: hard -"supabase@npm:^1.99.0": - version: 1.111.2 - resolution: "supabase@npm:1.111.2" +"supabase@npm:1.145.4": + version: 1.145.4 + resolution: "supabase@npm:1.145.4" dependencies: - bin-links: "npm:^4.0.1" + bin-links: "npm:^4.0.3" https-proxy-agent: "npm:^7.0.2" - node-fetch: "npm:^3.2.10" + node-fetch: "npm:^3.3.2" tar: "npm:6.2.0" bin: supabase: bin/supabase - checksum: 850766f5fd1fbe3dea9131a55d577ac998fb1cccdee28eeb0d478d786a96a5faad4d2e124afe4e82986a99b29d8bf214cf6eea7c2dee4d3fa87c02e13d2ed048 + checksum: 8b7d65ec1b84ebdd1053c925a444ed2d694aa1696ba8121c1779b8a964133990688e5aa27a481f192377db0f847e635581206dfa071b2f8e3f5e6bdbe5ee1d59 languageName: node linkType: hard