mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
# This workflow uses actions that are not certified by GitHub. They are
|
|
# provided by a third-party and are governed by separate terms of service,
|
|
# privacy policy, and support documentation.
|
|
#
|
|
# This workflow will install a prebuilt Ruby version, install dependencies, and
|
|
# run tests and linters.
|
|
name: "Ruby on Rails CI/CD"
|
|
on:
|
|
push:
|
|
branches: [ "main" ] # Jos repositoriosi päähaara ei ole main, muuta nämä
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-22.04
|
|
services:
|
|
postgres:
|
|
image: postgres:11-alpine
|
|
ports:
|
|
- "5432:5432"
|
|
env:
|
|
POSTGRES_DB: rails_test
|
|
POSTGRES_USER: rails
|
|
POSTGRES_PASSWORD: password
|
|
env:
|
|
RAILS_ENV: test
|
|
DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test"
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install Ruby and gems
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
bundler-cache: true
|
|
- name: Run tests
|
|
run: bundle exec rspec
|
|
- name: Run RuboCop
|
|
run: bundle exec rubocop --parallel
|
|
|
|
deploy:
|
|
runs-on: ubuntu-22.04
|
|
needs: test
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
- uses: superfly/flyctl-actions/setup-flyctl@master
|
|
- run: flyctl deploy --remote-only
|
|
env:
|
|
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|