-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·131 lines (129 loc) · 3.85 KB
/
backend.svc-consents.yaml
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: backend.svc-consents
on:
push:
branches:
- main
paths:
- .github/workflows/backend.svc-consents.yaml
- packages/backend/svc-consents/**
- packages/backend/tsconfig-backend.json
- package.json
- tsconfig.json
- types/**/*.ts
- '!**.md'
- '!**/.gitignore'
pull_request:
paths:
- .github/workflows/backend.svc-consents.yaml
- packages/backend/svc-consents/**
- packages/backend/tsconfig-backend.json
- package.json
- tsconfig.json
- types/**/*.ts
- '!**.md'
- '!**/.gitignore'
workflow_dispatch: null
env:
DOCKER_CONTEXT_PATH: .
DOCKERFILE: packages/backend/Dockerfile
PACKAGE: svc-consents
jobs:
test_unit:
name: Build, Lint, and Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16]
steps:
- name: Checkout git repository
uses: actions/checkout@master
- name: Using node.js ${{ matrix.node-version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: yarn install --immutable
- name: Build package
run: yarn workspace $PACKAGE build
- name: Lint package
run: yarn workspace $PACKAGE lint
- name: Run package unit tests
run: yarn workspace $PACKAGE test:unit
test_integration:
name: Test Integration
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16]
steps:
- name: Checkout git repository
uses: actions/checkout@master
- name: Copy db init scripts
run: |
sudo mkdir -p /home/db/scripts
sudo cp -r ${{ github.workspace }}/db/scripts/* /home/db/scripts/
sudo chmod 777 /home/db/scripts
- name: Using node.js ${{ matrix.node-version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: yarn install --immutable
- name: Run package integration tests
run: yarn workspace $PACKAGE test:integration:ci
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: granite
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: masterkey
POSTGRES_USER: granite
ports:
- 5432:5432
options: >-
-v /home/db/scripts:/docker-entrypoint-initdb.d
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
TYPEORM_HOST: 0.0.0.0
TYPEORM_PORT: 5432
TYPEORM_DATABASE: granite
TYPEORM_SCHEMA: public
TYPEORM_USERNAME: granite
TYPEORM_PASSWORD: masterkey
docker:
if: github.ref == 'refs/heads/main'
name: docker build and publish
runs-on: ubuntu-latest
needs:
- test_unit
- test_integration
steps:
- name: Checkout git repository
uses: actions/checkout@master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: nicolaspearson
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push latest version
uses: docker/build-push-action@master
with:
build-args: |
GITHUB_SHA=${{ github.sha }}
PACKAGE=${{ env.PACKAGE }}
cache-from: type=registry,ref=ghcr.io/nicolaspearson/${{ env.PACKAGE }}
cache-to: type=inline
context: ${{ env.DOCKER_CONTEXT_PATH }}
file: ${{ env.DOCKERFILE }}
platforms: linux/amd64
push: true
tags: |
ghcr.io/nicolaspearson/${{ env.PACKAGE }}:latest
ghcr.io/nicolaspearson/${{ env.PACKAGE }}:${{ github.sha }}