-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (122 loc) · 4.73 KB
/
node.js.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Node.js CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '0 */12 * * *'
jobs:
deploy-secrets-to-napptive:
needs: build
runs-on: ubuntu-latest
steps:
- run: |
curl --location --request POST 'https://api.github.com/repos/Jeff-Tian/uni-orders-secrets/dispatches' \
--header 'Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}' \
--header 'Accept: application/vnd.github+json' \
--header 'Content-Type: application/json' \
--data-raw '{"event_type": "webhook"}'
deploy-napptive:
name: Deploy to napptive
needs: deploy-secrets-to-napptive
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: napptive-actions/playground-github-action@v4.1.0
env:
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }}
with:
cmd: "apps deploy uni-orders.yaml"
update-napptive:
name: update napptive
if: ${{ always() }}
needs: deploy-napptive
runs-on: ubuntu-latest
env:
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }}
MY_OPENSSL_PASSWORD: ${{ secrets.MY_OPENSSL_PASSWORD }}
steps:
- run: echo "${PLAYGROUND_PAT}" | openssl enc -e -aes-256-cbc -a -pbkdf2 -iter 5 -k "${MY_OPENSSL_PASSWORD}"
- uses: actions/checkout@v2
- run: echo "Downloading NAPPTIVE Playground CLI"
- run: curl -O https://storage.googleapis.com/artifacts.playground.napptive.dev/installer.sh && bash installer.sh
- run: echo "Downloading Kubectl"
- run: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
- run: chmod +x kubectl
- run: echo "Login into NAPPTIVE Playground"
- run: playground login --pat
- run: playground get-kubeconfig
- run: ls ~/.napptive/default/napptive-kubeconfig
- name: update
env:
PLAYGROUND_PAT: ${{ secrets.PLAYGROUND_PAT }}
run: |
export PATH=$PATH:$(pwd)
echo "Forcing rolling update to download newest image"
export IMAGE="jefftian/uni-orders:latest"
echo "Update image... ${IMAGE}"
export PATCH='{"spec":{"workload":{"spec":{"containers":\ [{"name":"uni-orders", "image":"${IMAGE}"}]}}}}'
echo "patch = ${PATCH}"
kubectl --kubeconfig ~/.napptive/default/napptive-kubeconfig patch deploy uni-orders --patch '{"spec":{"template":{"spec":{"containers":[{"image":"jefftian/uni-orders","name":"uni-orders"}]}}}}' --type=merge
deploy-okteto:
if: ${{false}} # disable okteto deployment as my okteto env was deleted
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- run: curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- run: chmod +x ./kubectl
- run: sudo mv ./kubectl /usr/local/bin/kubectl
- run: mkdir ${HOME}/.kube
- run: npm i -g k8ss
- run: echo -e "machine github.com\n login ${{secrets.GH_TOKEN}}" > ~/.netrc
- run: git clone https://github.com/Jeff-Tian/k8s-config.git ${HOME}/k8s-config
- run: npm run okteto
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- run: yarn
- run: echo "${{secrets.DOCKER_PASSWORD}}" | docker login -u "${{secrets.DOCKER_USERNAME}}" --password-stdin
- run: sh .travis/ci.sh
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: nopwd
POSTGRES_USER: postgres
POSTGRES_DB: orders
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: yarn
- run: yarn build
- run: yarn test
- run: yarn test:e2e
- run: yarn test:cov