Skip to content

Commit e199657

Browse files
author
Herve Tribouilloy
committed
chore: add CI pipeline for tests and build
1 parent 319a3cf commit e199657

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build & publish widget
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
environment: production
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Install dependencies
24+
working-directory: vite_project
25+
run: npm install
26+
27+
- name: Build widget
28+
working-directory: vite_project
29+
run: npm run build
30+
31+
- name: Verify artifact exists
32+
run: |
33+
VERSION=$(node -p "require('./vite_project/package.json').version")
34+
test -f "www/widget-usp@${VERSION}.iife.js"
35+
36+
- name: Setup SSH
37+
run: |
38+
mkdir -p ~/.ssh
39+
echo "${{ secrets.WIDGET_SSH_KEY }}" > ~/.ssh/id_ed25519
40+
chmod 600 ~/.ssh/id_ed25519
41+
42+
if [ -z "${{ secrets.WIDGET_SSH_HOST }}" ]; then
43+
echo "ERROR: WIDGET_SSH_HOST not set (environment secrets not visible)"
44+
exit 1
45+
fi
46+
47+
ssh-keyscan -H "${{ secrets.WIDGET_SSH_HOST }}" >> ~/.ssh/known_hosts
48+
49+
- name: Publish artifact
50+
run: |
51+
VERSION=$(node -p "require('./vite_project/package.json').version")
52+
ssh ${{ secrets.WIDGET_SSH_USER }}@${{ secrets.WIDGET_SSH_HOST }} \
53+
"mkdir -p /var/www/widgets/usp"
54+
rsync -av \
55+
--chown=www-data:www-data \
56+
www/widget-usp@${VERSION}.iife.js* \
57+
${{ secrets.WIDGET_SSH_USER }}@${{ secrets.WIDGET_SSH_HOST }}:/var/www/widgets/usp/

0 commit comments

Comments
 (0)