diff --git a/.github/workflows/deploy_preview.yml b/.github/workflows/deploy_preview.yml new file mode 100644 index 0000000..596b844 --- /dev/null +++ b/.github/workflows/deploy_preview.yml @@ -0,0 +1,40 @@ +name: Vercel Preview Deployment + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + pull_request: + branches: [ "master" ] + workflow_dispatch: + +concurrency: + group: "vercel-preview-${{ github.event.pull_request.number }}" + cancel-in-progress: true + +jobs: + test: + uses: ./.github/workflows/tests.yml + + deploy-preview: + needs: [test] + runs-on: ubuntu-latest + # Do not run for PR from forks + if: github.event.pull_request.head.repo.full_name == github.repository + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Vercel CLI + run: npm install --global vercel@44.6.6 + + - 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/deploy_production.yml b/.github/workflows/deploy_production.yml new file mode 100644 index 0000000..0d710ee --- /dev/null +++ b/.github/workflows/deploy_production.yml @@ -0,0 +1,38 @@ +name: Vercel Production Deployment + +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + +on: + push: + branches: [ "master" ] + workflow_dispatch: + +concurrency: + group: "vercel-production-${{ github.ref }}" + cancel-in-progress: false # waits for the previous one to finish + +jobs: + test: + uses: ./.github/workflows/tests.yml + + deploy-production: + needs: [test] + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install Vercel CLI + run: npm install --global vercel@44.6.6 + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --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 --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d973520..eacaf27 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,10 +1,7 @@ name: Tests on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + workflow_call: workflow_dispatch: jobs: diff --git a/vercel.json b/vercel.json index 58b4f91..b8ddeaa 100644 --- a/vercel.json +++ b/vercel.json @@ -4,5 +4,9 @@ "src": "/(.*)", "dest": "/api/vercel_function" } - ] + ], + + "git": { + "deploymentEnabled": false + } }