Files
portfolio/.github/workflows/deploy.yml

73 lines
1.8 KiB
YAML

name: Deploy to server
on:
push:
branches:
- main
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: latest
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
- name: Install dependencies and build
run: |
pnpm install --frozen-lockfile
pnpm run build
env:
VITE_GITHUB_TOKEN: ${{ secrets.VITE_GITHUB_TOKEN }}
VITE_EMAILJS_SERVICE_ID: ${{ secrets.VITE_EMAILJS_SERVICE_ID }}
VITE_EMAILJS_TEMPLATE_ID: ${{ secrets.VITE_EMAILJS_TEMPLATE_ID }}
VITE_EMAILJS_USER_ID: ${{ secrets.VITE_EMAILJS_USER_ID }}
- name: Install Cypress binary
run: pnpx cypress install
- name: Install http-server
run: pnpm add -D http-server
- name: Start HTTP server
run: pnpx http-server ./dist -p 8080 &
env:
CI: true
- name: Run Cypress tests and Browserslist
run: pnpm run test
env:
CYPRESS_baseUrl: http://localhost:8080
- name: Upload Cypress screenshots
if: failure()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
path: cypress/screenshots
- name: Copy build directory to server
uses: Dylan700/sftp-upload-action@v1.2.3
with:
server: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
uploads: |
./dist => /webroot/
delete: true