-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (78 loc) · 2.57 KB
/
continuous-integration.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
name: Source Code CI/CD
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
jobs:
ci:
runs-on: ubuntu-latest
container:
image: node:12-alpine
services:
# More explanation about that here :
# https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
postgres:
image: postgres:12-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: jy95
POSTGRES_DB: sourcecode
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: jy95
POSTGRES_DB: sourcecode
# use postgres for the host here because we have specified a container for the job.
# If we were running the job on the VM this would be localhost
POSTGRES_HOST: postgres
# To specify the schema we want to use
DATABASE_SCHEMA: exercises_library
steps:
- uses: actions/checkout@v2
- name: Set DB Port
env:
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
run: |
echo "::set-env name=POSTGRES_PORT::$POSTGRES_PORT"
- name: Install
run: |
npm install -g npm@latest
npm ci
- name: Tests
env:
DATABASE_URL: 'postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@${{ env.POSTGRES_HOST }}:${{env.POSTGRES_PORT}}/${{env.POSTGRES_DB}}'
run: |
npm test
- name: Upload report to Codecov
run: |
apk add curl
apk add bash
curl -s https://codecov.io/bash > .codecov
chmod +x .codecov
./.codecov -t ${{ secrets.CODECOV_TOKEN }}
cd:
runs-on: ubuntu-latest
needs: ci
steps:
- uses: actions/checkout@v2
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build
run: docker build -t sourcecode_api .
- name: Tags
run: |
docker tag sourcecode_api ${{ secrets.DOCKER_USER }}/sourcecode_api:${{ github.sha }}
docker tag sourcecode_api ${{ secrets.DOCKER_USER }}/sourcecode_api:latest
- name: Push version
run: |
docker push ${{ secrets.DOCKER_USER }}/sourcecode_api:${{ github.sha }}
- name: Push release ( only on master )
if: github.ref == 'refs/heads/master'
run: |
docker push ${{ secrets.DOCKER_USER }}/sourcecode_api:latest