From 34329b0b88e89c8df200cd0b41d496e2675c65cf Mon Sep 17 00:00:00 2001 From: jis3r Date: Sun, 8 Dec 2024 21:59:04 +0100 Subject: [PATCH] feat: add GitHub Actions workflows for Vercel deployment in development and production environments --- .github/workflows/deploy.yml | 42 ++++++++++++++++++++++++++++++++++++ .github/workflows/dev.yml | 17 +++++++++++++++ .github/workflows/prod.yml | 19 ++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/prod.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..97ce396 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,42 @@ +name: "Deploy Vercel" + +on: + workflow_call: + inputs: + environment: + required: true + type: string + secrets: + VERCEL_TOKEN: + required: true + VERCEL_ORG_ID: + required: true + VERCEL_PROJECT_ID: + required: true + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4.1.7 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Install Vercel CLI + shell: bash + run: npm i -g vercel + - name: Install Dependencies + shell: bash + run: npm install + - name: Vercel Deploy + shell: bash + run: | + if [ "${{ inputs.environment }}" = "prod" ]; then + vercel pull --environment=production --yes --token=${{ secrets.vercel_token }} + vercel deploy --public --yes --prod --logs --token=${{ secrets.vercel_token }} + else + vercel pull --environment=preview --yes --token=${{ secrets.vercel_token }} + vercel deploy --public --yes --logs --token=${{ secrets.vercel_token }} + fi \ No newline at end of file diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..5cf6a95 --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,17 @@ +name: "Deploy Development" + +on: + push: + branches: + - development + +jobs: + dev: + name: "dev" + uses: ./.github/workflows/deploy.yml + with: + environment: "dev" + secrets: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml new file mode 100644 index 0000000..e80e891 --- /dev/null +++ b/.github/workflows/prod.yml @@ -0,0 +1,19 @@ +name: "Deploy Production" + +on: + push: + branches: + - main + repository_dispatch: + workflow_dispatch: + +jobs: + prod: + name: "prod" + uses: ./.github/workflows/deploy.yml + with: + environment: "prod" + secrets: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} \ No newline at end of file