-
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (107 loc) · 3.59 KB
/
build_deploy.yml
File metadata and controls
119 lines (107 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# .github/workflows/build_deploy.yml
name: Build and Deploy
# Set the following GitHub Secrets:
# SERVER_HOST – the IP or domain of your server
# SERVER_USER – the username for SSH
# SERVER_PASSWORD – password (or switch to using key for SSH key-based auth)
# SERVER_PORT – typically 22
# SERVER_TARGET – the path on the server where the files should go
on:
push:
branches:
- main
workflow_dispatch:
inputs:
run_full_deploy:
description: 'Trigger deployment of all static files'
required: false
default: false
type: boolean
env:
server_fingerprint: 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA2zJZx6VkSJC14SILqvzLiR3v8eS0D7Zs7C7771yDwa90UW8JkhK23dk/G8R74kdcWYEOn3kCSr/2rz+UtYThZeWUa5F6BcT/X5Gwh1RAlw5ESxnRr+hiZhYLI7BivVIo5EzecIs0KEojMRUkXI+ClHIcyXBY6grflQFgjZphFMs='
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build Astro project
run: pnpm build
- name: Archive build
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: dist/
deploy:
name: Deploy new static files via SFTP
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.run_full_deploy == 'false' }} # Only run deploy if 'run_full_deploy' input is 'false'
env:
onlyNewer: 'true'
options: 'ignore-time verbose=3 delete'
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: dist/
- name: Deploy static files via SFTP
uses: pressidium/lftp-mirror-action@v1
with:
# SFTP credentials
host: ${{ vars.SERVER_HOST }}
port: ${{ vars.SERVER_PORT }}
user: ${{ vars.SERVER_USER }}
pass: ${{ secrets.SERVER_PASSWORD }}
fingerprint: ${{ env.server_fingerprint }}
# lftp settings
onlyNewer: ${{ env.onlyNewer }}
restoreMTime: 'false'
parallel: '3'
# Mirror command options
localDir: './dist/'
remoteDir: ${{ vars.SERVER_TARGET }}
options: ${{ env.options }}
full-deploy:
name: Deploy all static files via SFTP
runs-on: ubuntu-latest
needs: build
if: ${{ github.event.inputs.run_full_deploy == 'true' }} # Only run full-deploy if 'run_full_deploy' input is 'true'
env:
onlyNewer: 'false'
options: 'verbose=3 delete'
steps:
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: dist/
- name: Deploy static files via SFTP
uses: pressidium/lftp-mirror-action@v1
with:
# SFTP credentials
host: ${{ vars.SERVER_HOST }}
port: ${{ vars.SERVER_PORT }}
user: ${{ vars.SERVER_USER }}
pass: ${{ secrets.SERVER_PASSWORD }}
fingerprint: ${{ env.server_fingerprint }}
# lftp settings
onlyNewer: ${{ env.onlyNewer }}
restoreMTime: 'false'
parallel: '3'
# Mirror command options
localDir: './dist/'
remoteDir: ${{ vars.SERVER_TARGET }}
options: ${{ env.options }}