Skip to content

Commit

Permalink
Github workflow edits
Browse files Browse the repository at this point in the history
  • Loading branch information
kmalick committed Oct 31, 2024
1 parent 69b7299 commit b5d4e37
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 64 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/docker-build.yml

This file was deleted.

100 changes: 100 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Ruby CI/CD

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest

env:
DATABASE_URL: mysql2://root:expertiza@localhost:3306/expertiza
RAILS_ENV: test
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: expertiza
MYSQL_DATABASE: expertiza_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v3

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.1
bundler-cache: true

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y netcat curl
- name: Install Ruby dependencies
run: |
gem update --system
gem install bundler:2.4.7
bundle install
- name: Setup database
run: |
bundle exec rails db:create
bundle exec rails db:schema:load
bundle exec rails db:seed
- name: Generate Swagger docs
run: RAILS_ENV=test bundle exec rake rswag:specs:swaggerize

- name: Run RSpec tests with coverage
run: |
bundle exec rspec --format documentation
- name: Run RuboCop
run: bundle exec rubocop

- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

docker:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/expertiza-backend:latest
${{ secrets.DOCKER_HUB_USERNAME }}/expertiza-backend:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/expertiza-backend:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/expertiza-backend:buildcache,mode=max
40 changes: 0 additions & 40 deletions .github/workflows/ruby-ci.yml

This file was deleted.

0 comments on commit b5d4e37

Please sign in to comment.