Files
portfolio/.github/workflows/deploy.yml

66 lines
1.5 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: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies and build
run: |
npm ci
npm run build
- name: Install http-server
run: npm install --save-dev http-server
- name: Start HTTP server
run: npx http-server ./dist -p 8080 &
env:
CI: true
- name: Run Cypress tests and Browserslist
run: npm 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: Get changed files
uses: tj-actions/changed-files@v41
with:
since_last_remote_commit: true
separator: ","
files: "./dist/***"
- name: copy file to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: ${{ steps.changed-files.outputs.all_changed_files }}
target: /webroot/