-
Notifications
You must be signed in to change notification settings - Fork 4
70 lines (68 loc) · 2.01 KB
/
docker_ci.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
name: Docker CI
on:
push:
branches:
- develop
- master
paths-ignore:
- "README.md"
tags:
- uat-*
- release-*
- v*
env:
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }}
jobs:
build_and_test_job:
runs-on: ubuntu-latest
env:
LOCALHOST: 127.0.0.1 # If we use 'localhost', rails tries to use a socket
services:
mysql:
image: mysql:8.0
ports:
- 3306:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_ROOT_PASSWORD: null
MYSQL_DATABASE: event_warehouse_test
rmq:
image: rabbitmq:3
ports:
- 5672:5672
env:
RABBITMQ_DEFAULT_USER: guest
RABBITMQ_DEFAULT_PASS: guest
steps:
- uses: actions/checkout@v4
- uses: nelonoel/[email protected]
- name: Build the Docker image
run: >-
docker build .
--file Dockerfile
--tag docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
- name: Run Rubocop against the image
run: >-
docker run --network host --env DBHOST=$LOCALHOST
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
bundle exec rubocop
- name: Initialize testing database
run: >-
docker run --network host --env DBHOST=$LOCALHOST
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
bundle exec rake db:create db:schema:load db:seed
- name: Run tests against the image
run: >-
docker run --network host --env DBHOST=$LOCALHOST
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}
bundle exec rspec
- name: Login to registry
run: >-
docker login
-u ${{ github.actor }}
-p ${{ secrets.GITHUB_TOKEN }}
docker.pkg.github.com
- name: Publish image with image tag being either develop/master/<tag_name>
run: >-
docker push
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME}