diff --git a/.github/workflows/preview-common.yaml b/.github/workflows/preview-common.yaml index 36182eb..c75d679 100644 --- a/.github/workflows/preview-common.yaml +++ b/.github/workflows/preview-common.yaml @@ -1,4 +1,3 @@ -# .github/workflows/common/preview.yaml name: Reusable Preview Workflow on: diff --git a/.github/workflows/production-common.yaml b/.github/workflows/production-common.yaml new file mode 100644 index 0000000..88851d2 --- /dev/null +++ b/.github/workflows/production-common.yaml @@ -0,0 +1,38 @@ +name: Reusable Production Workflow + +on: + workflow_call: + secrets: + vercel_project_name: + required: true + vercel_scope: + required: true + vercel_token: + required: true + +jobs: + shared-steps: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Enable Corepack + run: corepack enable + + - name: Install Corepack + run: corepack install + + - name: Link Project to Vercel + run: yarn dlx -q vercel link --project=$VERCEL_PROJECT_NAME --scope=$VERCEL_SCOPE --yes --token=$VERCEL_TOKEN + + - name: Pull Vercel Environment Information + run: yarn dlx -q vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: yarn dlx -q vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + + - name: Deploy Project Artifacts to Vercel + run: yarn dlx -q vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.github/workflows/production.yaml b/.github/workflows/production.yaml index 607b2db..086f10a 100644 --- a/.github/workflows/production.yaml +++ b/.github/workflows/production.yaml @@ -1,37 +1,20 @@ name: Vercel Production Deployment -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} - VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} - VERCEL_SCOPE: ${{ secrets.VERCEL_SCOPE }} - VERCEL_PROJECT_NAME: ${{ secrets.VERCEL_PROJECT_NAME }} + on: push: branches: - main jobs: - Deploy-Production: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Enable Corepack - run: corepack enable - - - name: Install Corepack - run: corepack install - - - name: Link Project to Vercel - run: yarn dlx -q vercel link --project=$VERCEL_PROJECT_NAME --scope=$VERCEL_SCOPE --yes --token=$VERCEL_TOKEN - - - name: Pull Vercel Environment Information - run: yarn dlx -q vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} - - - name: Build Project Artifacts - run: yarn dlx -q vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + default-example: + uses: ./.github/workflows/production-common.yaml + secrets: + vercel_project_name: ${{ secrets.VERCEL_NAME_EXAMPLE_DEFAULT }} + vercel_scope: ${{ secrets.VERCEL_SCOPE }} + vercel_token: ${{ secrets.VERCEL_TOKEN }} - - name: Deploy Project Artifacts to Vercel - run: yarn dlx -q vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} + upgrade-example: + uses: ./.github/workflows/production-common.yaml + secrets: + vercel_token: ${{ secrets.VERCEL_TOKEN }} + vercel_project_name: ${{ secrets.VERCEL_NAME_EXAMPLE_UPGRADE }} + vercel_scope: ${{ secrets.VERCEL_SCOPE }}