mirror of
https://github.com/BreizhHardware/portfolio.git
synced 2026-01-19 00:47:23 +01:00
59 lines
1.5 KiB
YAML
59 lines
1.5 KiB
YAML
name: Deploy to server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install dependencies and build
|
|
run: |
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Create GitHub deployment
|
|
id: create_deployment
|
|
uses: octokit/request-action@v2.x
|
|
with:
|
|
route: POST /repos/${{ github.repository }}/deployments
|
|
ref: ${{ github.sha }}
|
|
environment: production
|
|
required_contexts: []
|
|
|
|
- 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
|
|
|
|
- name: Update GitHub deployment status
|
|
if: success()
|
|
uses: octokit/request-action@v2.x
|
|
with:
|
|
route: POST /repos/${{ github.repository }}/deployments/${{ steps.create_deployment.outputs.data.id }}/statuses
|
|
state: success
|
|
environment: production
|
|
environment_url: https://mrqt.fr
|
|
log_url: https://mrqt.fr
|
|
description: Deployment succeeded
|
|
auto_inactive: true |