-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (60 loc) · 2.17 KB
/
deploy.yml
File metadata and controls
67 lines (60 loc) · 2.17 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
# SPDX-FileCopyrightText: 2025 Håkon Løvdal <kode@denkule.no>
#
# SPDX-License-Identifier: GPL-3.0-or-later
# This workflow will deploy to www.1maiprogram.no.
name: Deploy
permissions:
contents: read
on:
push:
branches: [ "main" ]
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [24.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm clean-install
- run: npm run build
- name: Copy dist files to server
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
port: ${{ secrets.DEPLOY_PORT }}
passphrase: ${{ secrets.DEPLOY_PASSPHRASE }}
source: dist/1maiprogram/browser
target: ${{ secrets.DEPLOY_WWW_PARENT_DIR }}/upload
- name: Atomically replace old www directory with new
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
port: ${{ secrets.DEPLOY_PORT }}
passphrase: ${{ secrets.DEPLOY_PASSPHRASE }}
script: |
set -euo pipefail
cd ${{ secrets.DEPLOY_WWW_PARENT_DIR }}
mkdir www.new
mv upload/dist/1maiprogram/browser/* upload/dist/1maiprogram/browser/.??* www.new/.
cp -ai www/.git* www.new/.
cd www.new
git add .
# Git commit will return with non-zero exit code if there are no files to commit
# (which is not necessarily an error, for instance when a new commit is pushed
# that only changes this file, there will be nothing in the www directory changed).
if ! git diff-index --cached --quiet HEAD; then git commit -m "$(date "+%Y-%m-%d_%H:%M")"; fi
cd ..
mv www www."$(date "+%Y-%m-%d_%H:%M")"
mv www.new www