Skip to content

Commit

Permalink
Add Deploy workflow
Browse files Browse the repository at this point in the history
- Extract tests from the CI workflow into a reusable workflow and call
  it from the original
- Add a deploy workflow to automatically deploy to Fly.io
- Call the reusable test workflow from the deploy workflow
  • Loading branch information
mauriciofierrom committed Dec 8, 2023
1 parent 2314d8a commit 82fd135
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
28 changes: 3 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
name: CI
on: [push, pull_request]
on: pull_request
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
- name: Build and run tests
env:
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
run: |
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:prepare
bundle exec rails test:all
bundle exec rspec
call-test:
uses: ./.github/workflows/test.yml
17 changes: 17 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy
on:
push:
branches:
- main
jobs:
call-test:
uses: ./.github/workflows/test.yml
deploy:
name: Deploy app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on: workflow_call
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server
steps:
- uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
- name: Build and run tests
env:
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
run: |
sudo apt-get -yqq install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:prepare
bundle exec rails test:all
bundle exec rspec

0 comments on commit 82fd135

Please sign in to comment.