-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.35 KB
/
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Run linting
run: |
bundle exec rubocop --parallel
- name: Run security checks
run: |
bundle exec bundler-audit --update
bundle exec brakeman -q -w2
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup database
env:
RAILS_ENV: "test"
run: |
bin/rails db:setup
- name: Check autoloading (zeitwerk)
env:
RAILS_ENV: "test"
run: |
bin/rails zeitwerk:check
- name: Run tests
env:
RAILS_ENV: "test"
run: |
bin/rails test
bin/rails test:system
deploy:
runs-on: ubuntu-latest
needs: [lint, test]
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Build production Docker image
run: |
docker build --tag ${{ secrets.REGISTRY_HOST }}/${{ secrets.REGISTRY_USERNAME }}/operum:main .
- name: Push Docker image
run: |
# The login is done with the default docker password storage, which is
# not the safest around, but it will be removed by a subsequent logout
# later on.
docker login -u "${{ secrets.REGISTRY_USERNAME }}" -p "${{ secrets.REGISTRY_PASSWORD }}" ${{ secrets.REGISTRY_HOST }}
docker push ${{ secrets.REGISTRY_HOST }}/${{ secrets.REGISTRY_USERNAME }}/operum:main
docker logout ${{ secrets.REGISTRY_HOST }}
# The server provides a small script named `service-restart` which will do
# the right thing to pull the new image of the desired service and re-run
# it.
- name: Restart service with the new code
uses: garygrossgarten/github-action-ssh@release
with:
command: infra-restart operum
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
passphrase: ${{ secrets.REMOTE_PASSPHRASE }}
privateKey: ${{ secrets.PRIVATE_KEY}}