From 774e71a17cb05786cdcfd44825febcdad1ad3e93 Mon Sep 17 00:00:00 2001 From: Matteo Badini Date: Thu, 14 Mar 2024 19:43:00 +0100 Subject: [PATCH] ci: github actions to deploy to vercel (#212) --- .github/workflows/merge-schema-changes.yml | 33 ---------------------- .github/workflows/vercel-preview.yaml | 29 +++++++++++++++++++ .github/workflows/vercel-production.yaml | 28 ++++++++++++++++++ 3 files changed, 57 insertions(+), 33 deletions(-) delete mode 100644 .github/workflows/merge-schema-changes.yml create mode 100644 .github/workflows/vercel-preview.yaml create mode 100644 .github/workflows/vercel-production.yaml diff --git a/.github/workflows/merge-schema-changes.yml b/.github/workflows/merge-schema-changes.yml deleted file mode 100644 index 4a9801a6..00000000 --- a/.github/workflows/merge-schema-changes.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Merge schema changes -on: - pull_request: - branches: [main] - types: [closed] - -jobs: - merge_changes: - runs-on: ubuntu-latest - if: github.event.pull_request.merged == true - steps: - - name: checkout - uses: actions/checkout@v3 - - name: Create a deploy request - uses: planetscale/create-deploy-request-action@v1 - id: create_deploy_request - with: - org_name: christer-sailsdock - database_name: propwrite - branch_name: develop # when we will have more branches ${{ github.event.pull_request.head.ref }} - env: - PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }} - PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }} - - name: Deploy a deploy request - uses: planetscale/deploy-deploy-request-action@v1 - with: - org_name: christer-sailsdock - database_name: propwrite - number: ${{ steps.create_deploy_request.outputs.number }} - wait: true - env: - PLANETSCALE_SERVICE_TOKEN_ID: ${{ secrets.PLANETSCALE_SERVICE_TOKEN_ID }} - PLANETSCALE_SERVICE_TOKEN: ${{ secrets.PLANETSCALE_SERVICE_TOKEN }} diff --git a/.github/workflows/vercel-preview.yaml b/.github/workflows/vercel-preview.yaml new file mode 100644 index 00000000..eea3d583 --- /dev/null +++ b/.github/workflows/vercel-preview.yaml @@ -0,0 +1,29 @@ +name: Vercel Preview Deployment + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches-ignore: + - "main" + - "renovate/**" + +jobs: + Deploy-Preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/vercel-production.yaml b/.github/workflows/vercel-production.yaml new file mode 100644 index 00000000..5ce8253c --- /dev/null +++ b/.github/workflows/vercel-production.yaml @@ -0,0 +1,28 @@ +name: Vercel Production Deployment + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches: + - main + +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}