-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (137 loc) · 3.93 KB
/
Copy pathcode.yaml
File metadata and controls
140 lines (137 loc) · 3.93 KB
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
137
138
139
140
name: code
on:
push:
branches:
- main
paths:
- .github/workflows/code.yaml
- package.json
- tsconfig.json
- src/*
- test/**/*.ts
pull_request:
paths:
- .github/workflows/code.yaml
- package.json
- tsconfig.json
- src/*
- test/**/*.ts
- types/**/*.ts
env:
DOCKER_CONTEXT_PATH: .
DOCKERFILE: Dockerfile
PACKAGE: dellingr
jobs:
test_unit:
name: Build, Lint, & Unit Test
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.4]
steps:
- name: Checkout git repository
uses: actions/checkout@v3
- name: Using node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: yarn install --immutable
- name: Build package
run: yarn build
- name: Lint package
run: yarn lint
- name: Run package unit tests
run: yarn test:unit
test_integration:
name: Test Integration
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.4]
steps:
- name: Checkout git repository
uses: actions/checkout@v3
- name: Copy db init scripts
run: |
sudo mkdir -p /home/scripts/db
sudo cp -r ${{ github.workspace }}/scripts/db/* /home/scripts/db/
sudo chmod 777 /home/scripts/db
- name: Using node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: yarn install --immutable
- name: Run package integration tests
run: yarn test:integration:ci
services:
localstack:
image: localstack/localstack:latest
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
DEFAULT_REGION: eu-west-1
SERVICES: s3
ports:
- 4510-4559:4510-4559
- 4566:4566
postgres:
image: postgres:14-alpine
env:
POSTGRES_DB: dellingr
POSTGRES_PORT: 5432
POSTGRES_PASSWORD: masterkey
POSTGRES_USER: admin
ports:
- 5432:5432
options: >-
-v /home/scripts/db:/docker-entrypoint-initdb.d
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
AWS__ACCESS_KEY_ID: test
AWS__ENDPOINT: http://0.0.0.0:4566
AWS__REGION: eu-west-1
AWS__SECRET_ACCESS_KEY: test
DATABASE__CREDENTIALS__DATABASE: dellingr
DATABASE__CREDENTIALS__SCHEMA: public
DATABASE__CREDENTIALS__HOST: 0.0.0.0
DATABASE__CREDENTIALS__PORT: 5432
DATABASE__CREDENTIALS__PASSWORD: masterkey
DATABASE__CREDENTIALS__USERNAME: admin
SEED_ENVIRONMENT: true
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@v3
- 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@v3
with:
build-args: |
GITHUB_SHA=${{ github.sha }}
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 }}