-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.55 KB
/
test_and_deploy.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
name: Test and deploy
on:
push:
# Allow manual triggering
workflow_dispatch:
jobs:
# Name of the job
rspec-test:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
# Service containers to run with job `test`
services:
postgres:
# Docker Hub image
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_DB: test
MAPBOX_ACCESS_TOKEN: ${{secrets.MAPBOX_ACCESS_TOKEN}}
# should not be empty
# https://stackoverflow.com/questions/60618118#answer-60618750
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
# Maps tcp port 5432 on service container to the host
ports: ["5432:5432"]
steps:
- name: Check out repository
uses: actions/checkout@v2
# https://github.com/ruby/setup-ruby
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.4 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup yarn dependencies
run: yarn install
- name: Run tests (PostgreSQL)
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test
RAILS_ENV: test
# Don't run RSpec with . https://olivierlacan.com/posts/a-tiny-little-dot/
# Show rspec errors as GH annotations https://github.com/Drieam/rspec-github#usage
run: |
cp config/database.ci.yml config/database.yml
bundle exec rails db:setup
bundle exec rspec spec/ --format documentation --format RSpec::Github::Formatter
# Name of the job
deploy:
# Deploy the main branch
if: github.ref == 'refs/heads/main'
# test job must succeed before this job is started
needs: rspec-test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
# https://github.com/marketplace/actions/deploy-to-heroku
- name: Deploy main to Heroku
uses: akhileshns/heroku-deploy@v3.12.12
with:
heroku_api_key: ${{secrets.HEROKU_API_KEY}}
heroku_app_name: "compass-red" #Must be unique in Heroku
heroku_email: "hpi.swt2+heroku@gmail.com"
env:
MAPBOX_ACCESS_TOKEN: ${{secrets.MAPBOX_PRODUCTION_ACCESS_TOKEN}}