-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (81 loc) · 2.58 KB
/
buildDeployMap.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
89
90
91
92
93
94
name: Build - Test- Publish - Deploy Map Service
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
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.0.2
bundler-cache: true
- name: Install dependent libraries
run: sudo apt-get install libpq-dev
- name: Bundle install
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
run: |
cp config/database.yml.github-actions config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
- name: Run RSpec
run: COVERAGE=true bundle exec rspec --require rails_helper
env:
RAILS_ENV: test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
build:
needs: test
if: (github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: satackey/[email protected]
continue-on-error: true
- name: Build Docker Image
run: docker build . --tag ghcr.io/the-microservice-dungeon/map/mapservice:latest
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Final Image
run: docker push ghcr.io/the-microservice-dungeon/map/mapservice:latest
deploy:
if: (github.ref == 'refs/heads/main')
needs: build
runs-on: ubuntu-latest
steps:
- name: stop-pull-run
uses: appleboy/ssh-action@master
env:
SERVICE_NAME: map
with:
host: cides03.gm.fh-koeln.de
username: ${{ secrets.PROD_USER }}
password: ${{ secrets.PROD_PWD }}
port: 22
envs: SERVICE_NAME
script: |
echo ${{ secrets.PROD_PWD }} | sudo -S docker-compose -f $SERVICE_NAME/service-compose.yml pull
echo ${{ secrets.PROD_PWD }} | sudo -S docker-compose -f $SERVICE_NAME/service-compose.yml up -d