Skip to content

Commit

Permalink
ci: add vercel github action
Browse files Browse the repository at this point in the history
  • Loading branch information
AliKdhim87 committed May 8, 2023
1 parent 97bee72 commit 0b873ce
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/deploy-website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deployment
on: [push, pull_request]
jobs:
vercel:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Get npm cache directory
id: npm-cache-dir
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v3
id: npm-cache
if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm
working-directory: ./pwa
- name: Lint
run: npm run lint
working-directory: ./pwa
- name: Build
run: npm run build
working-directory: ./pwa
- name: Start Deployment
uses: bobheadxi/[email protected]
id: deployment-preview
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: Preview
- name: Deploy to Preview
id: vercel-action-preview
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
scope: ${{ secrets.VERCEL_ORG_ID }}
working-directory: ./pwa
- name: Deploy to Production
uses: amondnet/vercel-action@v20
id: vercel-action-production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
github-comment: false
vercel-args: "--prod"
working-directory: ./pwa
- name: Update Deployment Status
uses: bobheadxi/[email protected]
if: github.ref != 'refs/heads/main'
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment-preview.outputs.deployment_id }}
env_url: ${{ steps.vercel-action-preview.outputs.preview-url }}
6 changes: 6 additions & 0 deletions pwa/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"github": {
"enabled": false,
"silent": true
}
}

0 comments on commit 0b873ce

Please sign in to comment.