Repository navigation
114 lines (110 loc) · 4.02 KB
/
Copy pathdeploy.yml
File metadata and controls
114 lines (110 loc) · 4.02 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
name: Deploy documentation
on:
push:
branches:
- develop
- main
workflow_dispatch:
permissions:
contents: read
concurrency:
group: deploy-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Fetch version metadata refs
run: |
git fetch --no-tags --depth=1 origin \
+refs/tags/nightly:refs/tags/nightly \
+refs/tags/stable:refs/tags/stable \
+refs/heads/develop:refs/remotes/origin/develop \
+refs/heads/main:refs/remotes/origin/main
- name: Set up pnpm and Node.js
uses: pnpm/setup@v3
with:
working-directory: docs
runtime: node@26
cache: true
require-lockfile: true
- name: Build
run: pnpm build
- name: Deploy to SFTP
if: github.ref == 'refs/heads/develop'
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_KEY: ${{ secrets.SFTP_KEY }}
SFTP_KNOWN_HOSTS: ${{secrets.SFTP_KNOWN_HOSTS}}
run: |
echo "$SFTP_KEY" > sftp_key
chmod 600 sftp_key
echo "$SFTP_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" dist/ $SFTP_USERNAME@$SFTP_HOST:/var/www/butterfly.linwood
web:
runs-on: ubuntu-26.04
timeout-minutes: 60
defaults:
run:
working-directory: app
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- uses: subosito/flutter-action@v2.23.0
with:
flutter-version-file: app/pubspec.yaml
cache: true
pub-cache-path: ${{ github.workspace }}/.offline-build/web/pub-cache
- name: Install helper dependencies
run: dart pub get -C ../tools --enforce-lockfile
- name: Install OneNote web toolchain
run: cargo install wasm-pack --version 0.15.0 --locked
- name: Get Git Commit Hash
run: echo "GIT_HASH=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Set flavor
if: github.ref != 'refs/heads/main'
run: |
echo "SETONIX_FLAVOR=nightly" >> $GITHUB_ENV
echo "WEB_DIR=preview" >> $GITHUB_ENV
cp -rf web_nightly/* web/
- name: Set flavor
if: github.ref == 'refs/heads/main'
run: |
echo "SETONIX_FLAVOR=stable" >> $GITHUB_ENV
echo "WEB_DIR=web" >> $GITHUB_ENV
- name: Build and prepare offline web dependencies
run: |
web_build_flavor=production
if [[ "$SETONIX_FLAVOR" == nightly ]]; then web_build_flavor=nightly; fi
dart ../tools/build_offline.dart prepare --platform web --flavor "$web_build_flavor" \
--dart-define="flavor=$SETONIX_FLAVOR" --dart-define="version=$GIT_HASH"
- name: Build web without network access
run: |
sudo unshare --net -- bash -euc '
ip link set lo up
exec runuser -u "$1" -- env PATH="$4" "$2" ../tools/build_offline.dart build --platform web --flutter "$3"
' offline-build "$(id -un)" "$(command -v dart)" "$(command -v flutter)" "$PATH"
- name: Deploy to SFTP
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USERNAME: ${{ secrets.SFTP_USERNAME }}
SFTP_KEY: ${{ secrets.SFTP_KEY }}
SFTP_KNOWN_HOSTS: ${{secrets.SFTP_KNOWN_HOSTS}}
run: |
echo "$SFTP_KEY" > sftp_key
chmod 600 sftp_key
echo "$SFTP_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
rsync -avz --delete -e "ssh -i sftp_key -o UserKnownHostsFile=known_hosts" build/web/ $SFTP_USERNAME@$SFTP_HOST:/var/www/$WEB_DIR.butterfly.linwood