Skip to content

Commit

Permalink
👷 Extend production workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cermakjiri committed Nov 21, 2024
1 parent 93f4262 commit e908d56
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 31 deletions.
1 change: 0 additions & 1 deletion .github/workflows/preview-common.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# .github/workflows/common/preview.yaml
name: Reusable Preview Workflow

on:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/production-common.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
43 changes: 13 additions & 30 deletions .github/workflows/production.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit e908d56

Please sign in to comment.