Skip to content

improve workflow

improve workflow #34

Workflow file for this run

name: CI
on:
push:
branches:
- main
- 'feature/**'
- 'hotfix/**'
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2.2
- name: Install dependencies
run: |
gem install bundler
bundle install
- name: Set up database
run: bundle exec rails db:create db:migrate
env:
RAILS_ENV: test
- name: Run tests
run: bundle exec rspec
env:
RAILS_ENV: test
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_PAT }}
- name: Prepare Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/loftwah/linkarooie
tags: |
type=ref,event=branch
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max