Skip to content

Fix Bundle

Fix Bundle #75

Workflow file for this run

name: CI & CD
on: [push]
env:
RAILS_ENV: test
CI: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: Run RSpec
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: opencourts_prokuratura_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup Credentials
run: |
mv config/credentials/test.ci.yml.enc config/credentials/test.yml.enc
mv config/credentials/test.ci.key config/credentials/test.key
- name: Install Required Packages
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libpq-dev libcurl4 libcurl4-openssl-dev ghostscript
- name: 'Read Ruby Version'
id: read-ruby-version
run: echo "RUBY_VERSION=$(cat .ruby-version)" >> $GITHUB_OUTPUT
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '${{ steps.read-ruby-version.outputs.RUBY_VERSION }}'
bundler-cache: true
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
- name: Install Yarn
run: npm install -g yarn
- name: Install Yarn
run: yarn install
- name: Setup Database
run: |
bin/rails db:create db:schema:load
bin/rails db:test:load_schema
- name: Prepare Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
# - name: Run RSpec
# run: bin/rspec
- name: Notify Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: ./cc-test-reporter after-build --coverage-input-type simplecov --exit-code $?
deploy:
name: Deploy to Production
needs: [test]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: github-actions
known_hosts: '...'
config: |
host otvorenesudy.sk
IdentityFile ~/.ssh/github-actions
IdentitiesOnly yes
ForwardAgent yes
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }}
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.0
bundler-cache: true
- name: Deploy
run: |
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github-actions
bundle exec cap production deploy deploy:restart sidekiq:restart