-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (70 loc) · 2.53 KB
/
deploy.yml
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
name: Deploy
on:
push:
branches: [ "master" ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 18.x
- name: Checkout database
uses: actions/checkout@v4
with:
path: database
- name: Install and export database
working-directory: ${{ github.workspace }}/database
run: |
npm install
npm run generate-all
- name: Checkout web
uses: actions/checkout@v4
with:
repository: XeroAlpha/caidlistweb
path: web
- name: Copy database files
run: |
cp -r ${{ github.workspace }}/database/output/web ${{ github.workspace }}/web/public/data
cp ${{ github.workspace }}/database/output/web/index.json ${{ github.workspace }}/web/src/assets/dataIndex.json
- name: Install and build web
working-directory: ${{ github.workspace }}/web
run: |
yarn install
yarn build
- name: Deploy to self-hosted site
if: github.repository == 'XeroAlpha/caidlist'
run: |
pushd ${{ github.workspace }}/web/dist
tar -cvzf ${{ github.workspace }}/idlist.tar.gz *
popd
echo "${{ secrets.SSH_KEY }}" > ${{ github.workspace }}/key.txt
chmod 400 ${{ github.workspace }}/key.txt
scp -q -P ${{ secrets.PORT }} -o StrictHostKeyChecking=no -i ${{ github.workspace }}/key.txt ${{ github.workspace }}/idlist.tar.gz "${{ secrets.USERNAME }}"@"${{ secrets.HOST }}":/tmp/idlist.tar.gz
ssh -q -p ${{ secrets.PORT }} -o StrictHostKeyChecking=no -i ${{ github.workspace }}/key.txt "${{ secrets.USERNAME }}"@"${{ secrets.HOST }}" "rm -rf ${{ secrets.TARGET_PATH }}/* && tar -xvzf /tmp/idlist.tar.gz -C ${{ secrets.TARGET_PATH }} && rm -f /tmp/idlist.tar.gz"
rm ${{ github.workspace }}/key.txt
- name: Setup GitHub Pages
id: pages_setup
uses: actions/configure-pages@v4
continue-on-error: true
- name: Upload artifact to GitHub pages
if: ${{ steps.pages_setup.outcome == 'success' }}
uses: actions/upload-pages-artifact@v3
with:
path: ${{ github.workspace }}/web/dist
- name: Deploy to GitHub Pages
if: ${{ steps.pages_setup.outcome == 'success' }}
id: deployment
uses: actions/deploy-pages@v4