|
1 | 1 | name: build-and-deploy |
2 | 2 |
|
3 | | -on: [push] |
| 3 | +on: [push,workflow_dispatch] |
4 | 4 |
|
5 | 5 | env: |
6 | 6 | BRANCH_NAME: ${{ github.ref_name }} |
|
9 | 9 | build-and-deploy: |
10 | 10 | runs-on: ubuntu-latest |
11 | 11 | steps: |
12 | | - - name: checkout code |
13 | | - uses: actions/checkout@v4 |
14 | | - - name: setup node |
15 | | - uses: actions/setup-node@v4 |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + - uses: actions/setup-node@v4 |
16 | 14 | with: |
17 | | - node-version: 20 |
18 | | -# cache: "npm" |
| 15 | + node-version: lts/* |
19 | 16 | - name: install slidevjs + playwright |
20 | 17 | run: 'npm i -g @slidev/cli && npm i -D playwright-chromium' |
| 18 | + - name: Get npm cache directory |
| 19 | + id: npm-cache-dir |
| 20 | + shell: bash |
| 21 | + run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} |
| 22 | + - name: Cache node modules |
| 23 | + uses: actions/cache@v4 |
| 24 | + id: cache |
| 25 | + with: |
| 26 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 27 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 28 | + restore-keys: | |
| 29 | + ${{ runner.os }}-node- |
| 30 | + - name: install dependencies |
| 31 | + if: steps.cache.outputs.cache-hit != 'true' |
| 32 | + run: 'npm i' |
21 | 33 | - name: build slides |
22 | 34 | run: 'yes | slidev build' |
23 | | -# - name: upload build |
24 | | -# uses: actions/upload-artifact@v3 |
25 | | -# with: |
26 | | -# name: build |
27 | | -# path: dist |
28 | | - - name: Install Netlify |
29 | | - run: npm install [email protected] -g |
| 35 | + - name: Get short commit SHA |
| 36 | + id: vars |
| 37 | + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT |
30 | 38 | - name: Deploy to Netlify |
31 | 39 | id: netlify_deploy |
32 | 40 | run: | |
33 | 41 | prod_flag="" |
34 | 42 | if [ "$BRANCH_NAME" = "main" ]; then prod_flag="--prod"; fi |
35 | 43 | netlify deploy \ |
36 | | - --dir dist \ |
| 44 | + --dir dist \ |
| 45 | + --message "CLI deploy via ${{ github.ref_name }}: commit ${{ steps.vars.outputs.sha_short }}, ${{ github.event.commits[0].message }}" \ |
37 | 46 | --site ${{ secrets.NETLIFY_SITE_ID }} \ |
38 | 47 | --auth ${{ secrets.NETLIFY_AUTH_TOKEN }} \ |
39 | 48 | $prod_flag |
40 | | - |
41 | | -# deploy: |
42 | | -# needs: build |
43 | | -# runs-on: ubuntu-latest |
44 | | -# name: 'Deploy to Netlify' |
45 | | -# steps: |
46 | | -# - uses: jsmrcaga/[email protected] |
47 | | -# with: |
48 | | -# build_directory: dist |
49 | | -# build_command: 'npm i -g @slidev/cli ; npm i -D playwright-chromium ; yes | slidev build' |
50 | | -# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
51 | | -# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
52 | | -# NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}" |
53 | | -# NETLIFY_DEPLOY_TO_PROD: true |
0 commit comments