Extract travel stats into content folder #670
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD Pipeline | |
on: | |
push: | |
env: | |
NODE_VERSION: '18.x' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Lint & Format checks | |
run: | | |
npm ci | |
npm run lint | |
npm run format | |
- name: Build | |
run: | | |
npm run build | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Cypress run | |
uses: cypress-io/github-action@v5 | |
with: | |
build: npm run build | |
start: npm start | |
wait-on: http://localhost:3000 | |
deploy-preview: | |
name: Deploy to preview | |
needs: [build, test] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Deploy with Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Deploy to preview environment | |
run: | | |
npm i -g vercel | |
vercel --token "$VERCEL_TOKEN" > preview-deployment-url.txt | |
cat preview-deployment-url.txt | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: preview-deployment-url | |
path: preview-deployment-url.txt | |
check-performance: | |
name: Check performance | |
needs: deploy-preview | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download preview deployment URL | |
uses: actions/download-artifact@v3 | |
with: | |
name: preview-deployment-url | |
- name: Run with Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Check performance with Lighthouse | |
run: | | |
deployment_url=`cat preview-deployment-url.txt` | |
npm i -g @lhci/[email protected] | |
npm run performance:check -- $deployment_url | |
env: | |
LHCI_GITHUB_TOKEN: ${{ secrets.LHCI_GITHUB_TOKEN }} | |
deploy-prod: | |
name: Deploy to prod | |
needs: check-performance | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Deploy with Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Deploy to prod environment | |
run: | | |
npm i -g vercel | |
vercel --token "$VERCEL_TOKEN" --prod | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} |