|
4 | 4 | push:
|
5 | 5 | branches:
|
6 | 6 | - master # default branch
|
| 7 | + - chore-nuxt-deploy # Test only |
7 | 8 |
|
8 | 9 | jobs:
|
9 | 10 | build:
|
10 | 11 | runs-on: ubuntu-latest
|
11 |
| - permissions: |
12 |
| - contents: write |
13 | 12 | steps:
|
14 |
| - - uses: actions/checkout@v2 |
| 13 | + - uses: actions/checkout@v5 |
15 | 14 | - name: Use Node.js 22
|
16 |
| - uses: actions/setup-node@v4 |
| 15 | + uses: actions/setup-node@v5 |
17 | 16 | with:
|
18 | 17 | node-version: '22'
|
19 |
| - - name: Cache NPM dependencies |
20 |
| - uses: actions/cache@v4 |
| 18 | + |
| 19 | + # https://github.com/actions/cache/blob/v4/examples.md#node---npm |
| 20 | + - name: Get npm cache directory |
| 21 | + id: npm-cache-dir |
| 22 | + shell: bash |
| 23 | + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} |
| 24 | + - uses: actions/cache@v4 |
| 25 | + id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' |
21 | 26 | with:
|
22 |
| - path: node_modules |
23 |
| - key: ${{ runner.OS }}-npm-cache |
| 27 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 28 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
24 | 29 | restore-keys: |
|
25 |
| - ${{ runner.OS }}-npm-cache |
26 |
| - - name: Setup SSH Private Key |
27 |
| - env: |
28 |
| - KEY: ${{ secrets.KEY }} |
29 |
| - IP: ${{ secrets.IP }} |
30 |
| - run: | |
31 |
| - mkdir -p ~/.ssh/ |
32 |
| - echo "$KEY" > ~/.ssh/id_rsa |
33 |
| - chmod 600 ~/.ssh/id_rsa |
34 |
| - ssh-keyscan $IP >> ~/.ssh/known_hosts |
35 |
| - - name: Install deps |
36 |
| - run: | |
37 |
| - sudo apt install expect tcl-expect -y |
38 |
| - - name: Upload website |
39 |
| - env: |
40 |
| - IP: ${{ secrets.IP }} |
41 |
| - run: | |
42 |
| - rm -rf website* |
43 |
| -
|
44 |
| - # Build utilities |
45 |
| - git submodule update --init |
46 |
| - pushd utils/make-news-index |
47 |
| - go build -o make-news-index |
48 |
| - popd |
| 30 | + ${{ runner.os }}-node- |
49 | 31 |
|
50 |
| - # Build news index |
51 |
| - pushd public |
52 |
| - ../utils/make-news-index/make-news-index |
53 |
| - popd |
| 32 | + - name: Install dependencies |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: Build |
| 36 | + run: npm run generate |
54 | 37 |
|
55 |
| - # Build website |
56 |
| - npm i |
57 |
| - npm run build |
58 |
| -
|
59 |
| - zip -r website.zip website/ |
60 |
| - scp website.zip aosc@$IP:/home/aosc/web/ |
61 |
| - - name: Unzip website |
62 |
| - run: | |
63 |
| - cd deploy |
64 |
| - ./unzipServer.sh |
| 38 | + - name: Copy files via SSH |
| 39 | + uses: appleboy/scp-action@v1 |
| 40 | + with: |
| 41 | + host: ${{ secrets.IP }} |
| 42 | + username: aosc |
| 43 | + key: ${{ secrets.KEY }} |
| 44 | + source: ".output/public" |
| 45 | + target: /home/aosc/web/website-nuxt #Test bnly |
| 46 | + rm: true |
0 commit comments