99 deploy_path :
1010 required : true
1111 type : string
12+ deploy_type :
13+ required : true
14+ type : string
15+ description : ' Type of deployment: "samples" (reference player + samples) or "build" (dist artifacts + JSDoc)'
1216 secrets :
1317 host :
1418 required : true
@@ -23,23 +27,21 @@ jobs:
2327
2428 steps :
2529 - uses : actions/checkout@v4
26- - name : Use Node.js
27- uses : actions/setup-node@v4
28- with :
29- node-version : " 20.x"
30- - name : Install dependencies
31- run : npm install
30+ - name : Setup dash.js
31+ uses : ./.github/actions/setup-dashjs
3232 - name : Run build
3333 run : npm run build
3434 - name : Find and Replace
35+ if : inputs.deploy_type == 'samples'
3536 uses : jacobtomlinson/gha-find-replace@v2
3637 env :
3738 replacement_string : ${{ format('{0} - commit <a href="https://github.com/Dash-Industry-Forum/dash.js/commit/{1}">{2}</a>', github.ref_name, github.sha, github.sha)}}
3839 with :
3940 find : " <!-- commit-info -->"
4041 replace : ${{env.replacement_string}}
41- include : " samples/dash-if-reference-player/index.html"
42+ include : " samples/dash-if-reference-player* /index.html"
4243 - name : Build all samples
44+ if : inputs.deploy_type == 'samples'
4345 run : |
4446 for sample in "network-interceptor"; do
4547 echo "Building sample: $sample"
@@ -48,16 +50,37 @@ jobs:
4850 npm run build
4951 rm -rf node_modules
5052 done
51- - name : Copy to deploy directory for deployment
53+ - name : Build JSDoc
54+ if : inputs.deploy_type == 'build'
55+ run : npm run doc
56+ continue-on-error : true
57+ - name : Copy samples to deploy directory
58+ if : inputs.deploy_type == 'samples'
59+ env :
60+ ENVNAME : ${{ inputs.envname }}
5261 run : |
53- mkdir -p ${{inputs.envname}}
54- cp -R contrib dist samples ${{inputs.envname}}
62+ mkdir -p "$ENVNAME"
63+ cp -R contrib dist samples "$ENVNAME"
64+ - name : Copy build artifacts to deploy directory
65+ if : inputs.deploy_type == 'build'
66+ env :
67+ ENVNAME : ${{ inputs.envname }}
68+ run : |
69+ mkdir -p "$ENVNAME"
70+ cp -R docs/jsdoc "$ENVNAME/jsdoc" && cp -R dist/modern/umd/* "$ENVNAME" && cp -R dist/* index.d.ts "$ENVNAME"
5571 - name : Install SSH Key
5672 uses : shimataro/ssh-key-action@v2
5773 with :
5874 key : ${{ secrets.private_key }}
5975 known_hosts : unnecessary
76+ - name : Fetch host keys
77+ run : ssh-keyscan -H ${{ secrets.host }} >> ~/.ssh/known_hosts
6078 - name : Deploy with scp
79+ env :
80+ DEPLOY_USER : ${{ secrets.user }}
81+ DEPLOY_HOST : ${{ secrets.host }}
82+ DEPLOY_PATH : ${{ inputs.deploy_path }}
83+ ENVNAME : ${{ inputs.envname }}
6184 run : |
62- ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-dss ${{ secrets.USER }}@${{ secrets.HOST }} "mkdir -p ${{ inputs.deploy_path }}/${{inputs.envname}} "
63- scp -r -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-dss ${{inputs.envname}} ${{ secrets.user }}@${{ secrets.host }}:${{ inputs.deploy_path }}
85+ ssh "$DEPLOY_USER@$DEPLOY_HOST" "mkdir -p \"$DEPLOY_PATH/$ENVNAME\" "
86+ scp -r "$ENVNAME" "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH"
0 commit comments