Skip to content

Commit 03ed63f

Browse files
authored
CD Update for Contributions (#40)
* Split out a dev and prod deploy * CD update poc * CD update poc * CD update poc * CD update poc * CD update poc * CD update poc * CD update poc * CD update poc * update dependencies and remove code causing errors for CI/CD * can these be master? * no they cannot * CD update working * lets test this * lets test this * Point to main and bring back real deployment code
1 parent 16d1694 commit 03ed63f

6 files changed

Lines changed: 546 additions & 368 deletions

File tree

.github/workflows/cd.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/cd_dev.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: TinyNode Dev Deploy on PR to main
2+
on:
3+
pull_request:
4+
branches: main
5+
jobs:
6+
merge-branch:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- name: Merge with main
11+
uses: devmasx/merge-branch@master
12+
with:
13+
type: now
14+
from_branch: main
15+
target_branch: ${{ github.head_ref }}
16+
github_token: ${{ secrets.BRY_PAT }}
17+
message: Merge main into this branch to deploy to dev for testing.
18+
test:
19+
needs: merge-branch
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@master
23+
- name: Create .env from secrets
24+
uses: SpicyPizza/create-envfile@v2
25+
with:
26+
envkey_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
27+
envkey_REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
28+
envkey_RERUM_REGISTRATION_URL: ${{ secrets.RERUM_REGISTRATION_URL }}
29+
envkey_RERUM_API_ADDR: ${{ secrets.RERUM_API_ADDR }}
30+
envkey_RERUM_ID_PATTERN: ${{ secrets.RERUM_ID_PATTERN }}
31+
envkey_RERUM_ACCESS_TOKEN_URL: ${{ secrets.RERUM_ACCESS_TOKEN_URL }}
32+
- name: Setup Node.js
33+
uses: actions/setup-node@master
34+
with:
35+
node-version: "16"
36+
- name: Cache node modules
37+
uses: actions/cache@master
38+
env:
39+
cache-name: cache-node-modules
40+
with:
41+
path: ~/.npm
42+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{
43+
hashFiles('**/package-lock.json') }}
44+
restore-keys: |
45+
${{ runner.os }}-build-${{ env.cache-name }}-
46+
${{ runner.os }}-build-
47+
${{ runner.os }}-
48+
- name: Install dependencies and run the test
49+
run: |
50+
npm install
51+
npm run runtest
52+
deploy:
53+
if: github.event.pull_request.draft == false
54+
needs:
55+
- merge-branch
56+
- test
57+
strategy:
58+
matrix:
59+
machines:
60+
- vlcdhp02
61+
runs-on: ${{ matrix.machines }}
62+
steps:
63+
- uses: actions/checkout@master
64+
- name: Deploy the app on the server
65+
run: |
66+
if [[ ! -e /srv/node/logs/tinynode.txt ]]; then
67+
mkdir -p /srv/node/logs
68+
touch /srv/node/logs/tinynode.txt
69+
fi
70+
cd /srv/node/tiny-node/
71+
pm2 stop tinyNode
72+
git stash
73+
git pull
74+
npm install
75+
pm2 start -i max bin/tinyNode.js

.github/workflows/cd_prod.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: TinyNode production deploy on push to main.
2+
on:
3+
push:
4+
branches: main
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- name: Create .env from secrets
11+
uses: SpicyPizza/create-envfile@v2
12+
with:
13+
envkey_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
14+
envkey_REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}
15+
envkey_RERUM_REGISTRATION_URL: ${{ secrets.RERUM_REGISTRATION_URL }}
16+
envkey_RERUM_API_ADDR: ${{ secrets.RERUM_API_ADDR }}
17+
envkey_RERUM_ID_PATTERN: ${{ secrets.RERUM_ID_PATTERN }}
18+
envkey_RERUM_ACCESS_TOKEN_URL: ${{ secrets.RERUM_ACCESS_TOKEN_URL }}
19+
- name: Setup Node.js
20+
uses: actions/setup-node@master
21+
with:
22+
node-version: "16"
23+
- name: Cache node modules
24+
uses: actions/cache@master
25+
env:
26+
cache-name: cache-node-modules
27+
with:
28+
path: ~/.npm
29+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{
30+
hashFiles('**/package-lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-build-${{ env.cache-name }}-
33+
${{ runner.os }}-build-
34+
${{ runner.os }}-
35+
- name: Install dependencies and run the test
36+
run: |
37+
npm install
38+
npm run runtest
39+
deploy:
40+
needs:
41+
- test
42+
strategy:
43+
matrix:
44+
machines:
45+
- vlcdhprdp02
46+
runs-on: ${{ matrix.machines }}
47+
steps:
48+
- uses: actions/checkout@master
49+
- name: Deploy the app on the server
50+
run: |
51+
if [[ ! -e /srv/node/logs/tinynode.txt ]]; then
52+
mkdir -p /srv/node/logs
53+
touch /srv/node/logs/tinynode.txt
54+
fi
55+
cd /srv/node/tiny-node/
56+
pm2 stop tinyNode
57+
git stash
58+
git pull
59+
npm install
60+
pm2 start -i max bin/tinyNode.js

.github/workflows/test.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)