-
Notifications
You must be signed in to change notification settings - Fork 2
113 lines (98 loc) · 2.79 KB
/
ruby.yml
File metadata and controls
113 lines (98 loc) · 2.79 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
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:13
ports: ['5432:5432']
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.1
bundler-cache: true
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get -yqq install libpq-dev
sudo apt-get install -y postgresql-client
gem install bundler
bundle install --jobs 4 --retry 3
- name: Cache assets
uses: actions/cache@v4
with:
path: public/assets
key: ${{ runner.os }}-assets-${{ github.sha }}
restore-keys: |
${{ runner.os }}-assets
- name: Cleanup tmp dirs
run: |
rm -rf tmp/storage
rm -rf tmp/screenshots
rm -rf tmp/capybara
- name: Migrate Database
env:
RAILS_ENV: test
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_URL: postgres://postgres:@localhost:5432
run: |
bundle exec rake db:create
bundle exec rake db:migrate
- name: Precompile Assets
env:
RAILS_ENV: test
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_URL: postgres://postgres:@localhost:5432
run: |
bundle exec rake assets:clobber
bundle exec rake assets:precompile
- name: Run Tests
env:
RAILS_ENV: test
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
DATABASE_URL: postgres://postgres:@localhost:5432
CI: true
run: |
bundle exec rake test
- name: Save assets back to cache
uses: actions/cache@v4
with:
path: public/assets
key: ${{ runner.os }}-assets-${{ github.sha }}
build_image:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/master'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name == 'release' }}
build-args: |
APP_ENV=prod
tags: |
ghcr.io/mindleaps/tracker/mindleaps-tracker:latest
ghcr.io/mindleaps/tracker/mindleaps-tracker:${{ github.event.release.tag_name }}