-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (81 loc) · 2.34 KB
/
ci-cd.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
name: ci-cd
on: push
jobs:
test:
environment: development
runs-on: ubuntu-22.04
container: tyknkd/spark:3.3.2-scala2.13-jdk17-gradle8.7-jammy
env:
NEWS_API_KEY: ${{ secrets.NEWS_API_KEY }}
OS_ENV: container
PGPASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_DB: collector_db
POSTGRES_HOST: db
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_USER: newsanalyzer
services:
db:
image: postgres:16.2
env:
POSTGRES_DB: ${{ env.POSTGRES_DB }}
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
POSTGRES_USER: ${{ env.POSTGRES_USER }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mq:
image: rabbitmq:3.13-management
ports:
- 5672:5672
- 15692:15692
options: >-
--health-cmd "rabbitmq-diagnostics check_port_connectivity"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Install PostgreSQL client
run: |
apt update
apt install -y postgresql-client
- name: Check out repository
uses: actions/checkout@v4
- name: Initialize databases
shell: bash
run: |
source .env
chmod +x ./docker-databases/docker-entrypoint-initdb.d/init-additional-db.sh
./docker-databases/docker-entrypoint-initdb.d/init-additional-db.sh
- name: Run tests
shell: bash
run: |
source .env
gradle test
build:
needs: test
if: github.ref == 'refs/heads/main'
environment: production
runs-on: ubuntu-22.04
steps:
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Check out repository
uses: actions/checkout@v4
- name: Build and push Docker images
shell: bash
run: docker compose build --push data-collector data-analyzer web-server
deploy:
needs: build
if: github.ref == 'refs/heads/main'
environment: production
runs-on: ubuntu-22.04
steps:
- name: Deploy
run: exit 0