Skip to content

Commit 4dc0e25

Browse files
authored
Feature/ci deployment (Dash-Industry-Forum#4729)
* Add CI/CD job to deploy latest version using version number from package.json
1 parent cd95955 commit 4dc0e25

File tree

7 files changed

+149
-5
lines changed

7 files changed

+149
-5
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
done
5151
- name: Copy to deploy directory for deployment
5252
run: |
53-
mkdir ${{inputs.envname}}
53+
mkdir -p ${{inputs.envname}}
5454
cp -R contrib dist samples ${{inputs.envname}}
5555
- name: Install SSH Key
5656
uses: shimataro/ssh-key-action@v2
@@ -59,4 +59,5 @@ jobs:
5959
known_hosts: unnecessary
6060
- name: Deploy with scp
6161
run: |
62-
scp -r -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-dss ${{inputs.envname}} ${{ secrets.user }}@${{ secrets.host }}:${{ inputs.deploy_path }}
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 }}

.github/workflows/deploy_build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: deploy_build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
envname:
7+
required: true
8+
type: string
9+
deploy_path:
10+
required: true
11+
type: string
12+
secrets:
13+
host:
14+
required: true
15+
user:
16+
required: true
17+
private_key:
18+
required: true
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- 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
32+
- name: Build dist files
33+
run: npm run build
34+
- name: Build JSDoc
35+
run: npm run doc
36+
continue-on-error: true
37+
- name: Copy to deploy directory for deployment
38+
run: |
39+
mkdir -p ${{inputs.envname}}
40+
cp -R docs/jsdoc ${{inputs.envname}}/jsdoc && cp -R dist/modern/umd/* ${{inputs.envname}} && cp -R dist/* index.d.ts ${{inputs.envname}}
41+
- name: Install SSH Key
42+
uses: shimataro/ssh-key-action@v2
43+
with:
44+
key: ${{ secrets.private_key }}
45+
known_hosts: unnecessary
46+
- name: Deploy with scp
47+
run: |
48+
ssh -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-dss ${{ secrets.USER }}@${{ secrets.HOST }} "mkdir -p ${{ inputs.deploy_path }}/${{inputs.envname}}"
49+
scp -r -o StrictHostKeyChecking=no -oHostKeyAlgorithms=+ssh-dss ${{inputs.envname}} ${{ secrets.user }}@${{ secrets.host }}:${{ inputs.deploy_path }}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: deploy_latest
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
deploy_latest:
10+
if: github.repository == 'Dash-Industry-Forum/dash.js'
11+
uses: ./.github/workflows/deploy_build.yml
12+
with:
13+
envname: latest
14+
deploy_path: '/377335'
15+
secrets:
16+
host: ${{secrets.HOST}}
17+
user: ${{secrets.USER}}
18+
private_key: ${{secrets.PRIVATE_KEY}}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: deploy_build_latest_as_version_folder
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
get_version_number:
10+
if: github.repository == 'Dash-Industry-Forum/dash.js'
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.set_version.outputs.version }}
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Read version from package.json
19+
id: set_version
20+
run: |
21+
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
22+
shell: bash
23+
24+
- name: Print version
25+
run: |
26+
echo "Version: ${{ steps.set_version.outputs.version }}"
27+
28+
deploy:
29+
if: github.repository == 'Dash-Industry-Forum/dash.js'
30+
needs: get_version_number
31+
uses: ./.github/workflows/deploy_build.yml
32+
with:
33+
envname: v${{ needs.get_version_number.outputs.version }}
34+
deploy_path: '/377335'
35+
secrets:
36+
host: ${{ secrets.HOST }}
37+
user: ${{ secrets.USER }}
38+
private_key: ${{ secrets.PRIVATE_KEY }}

.github/workflows/deploy_latest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- 'master'
77

88
jobs:
9-
deploy_staging:
9+
deploy_latest:
1010
if: github.repository == 'Dash-Industry-Forum/dash.js'
1111
uses: ./.github/workflows/deploy.yml
1212
with:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: deploy_latest_as_version_folder
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
get_version_number:
10+
if: github.repository == 'Dash-Industry-Forum/dash.js'
11+
runs-on: ubuntu-latest
12+
outputs:
13+
version: ${{ steps.set_version.outputs.version }}
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v4
17+
18+
- name: Read version from package.json
19+
id: set_version
20+
run: |
21+
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
22+
shell: bash
23+
24+
- name: Print version
25+
run: |
26+
echo "Version: ${{ steps.set_version.outputs.version }}"
27+
28+
deploy:
29+
if: github.repository == 'Dash-Industry-Forum/dash.js'
30+
needs: get_version_number
31+
uses: ./.github/workflows/deploy.yml
32+
with:
33+
envname: v${{ needs.get_version_number.outputs.version }}
34+
deploy_path: '/377335/dash.js'
35+
secrets:
36+
host: ${{ secrets.HOST }}
37+
user: ${{ secrets.USER }}
38+
private_key: ${{ secrets.PRIVATE_KEY }}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)