-
-
Notifications
You must be signed in to change notification settings - Fork 54
131 lines (125 loc) · 3.68 KB
/
main.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
name: CI/CD
on:
pull_request:
paths-ignore:
- '.vscode/**'
- 'docs/**'
- 'env/**'
- '**/*.md'
- '.gitpod.yml'
push:
branches:
- master
paths-ignore:
- '.vscode/**'
- 'docs/**'
- 'env/**'
- '**/*.md'
- '.gitpod.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "yarn"
- run: npm install -g yarn
- run: yarn install --frozen-lockfile
- run: yarn run lint-ci
env:
NODE_ENV: production
- name: cargo-install
uses: baptiste0928/cargo-install@v1
with:
crate: typeshare-cli
version: "1.7.0"
- name: Ensure generated code is up to date
run: ./scripts/codegen.sh && git diff --exit-code
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
continue-on-error: true
services:
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v1
- name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- uses: actions/cache@v1
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "yarn"
- run: npm install -g yarn
- run: yarn install --frozen-lockfile
- run: yarn workspace ott-server run sequelize db:migrate
env:
NODE_ENV: test
- run: yarn workspace ott-client build
- run: yarn run test
env:
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Upload coverage report
uses: codecov/codecov-action@v2
with:
files: ./common/coverage/coverage-final.json,./client/coverage/coverage-final.json,./server/coverage/coverage-final.json
deploy-docker:
runs-on: ubuntu-latest
name: Deploy docker image
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint]
steps:
- uses: actions/checkout@v1
- name: Log in to Dockerhub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "dyc3" --password-stdin
touch env/production.env
- name: Build image
run: |
docker-compose -f docker/docker-compose.yml up -d --build
docker commit opentogethertube opentogethertube
docker-compose -f docker/docker-compose.yml down
docker tag opentogethertube dyc3/opentogethertube:latest
- name: Push to Dockerhub
run: docker push dyc3/opentogethertube:latest
deploy-fly:
runs-on: ubuntu-latest
name: Deploy on fly.io
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test, lint]
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --config deploy/fly.prod.monolith.toml --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}