dawarich/.circleci/config.yml
2025-02-02 22:40:58 +01:00

82 lines
1.9 KiB
YAML

version: 2.1
parameters:
tag:
type: string
default: "rc"
executors:
docker-executor:
machine:
image: ubuntu-2204:current
orbs:
ruby: circleci/ruby@2.1.4
browser-tools: circleci/browser-tools@1.4.8
docker: circleci/docker@2.8.2
jobs:
test:
docker:
- image: cimg/ruby:3.3.4
environment:
RAILS_ENV: test
- image: cimg/postgres:13.3-postgis
environment:
POSTGRES_USER: postgres
POSTGRES_DB: test_database
POSTGRES_PASSWORD: mysecretpassword
- image: redis:7.0
steps:
- checkout
- run:
name: Install Bundler
command: gem install bundler
- run:
name: Bundle Install
command: bundle install --jobs=4 --retry=3
- run:
name: Database Setup
command: |
bundle exec rails db:create
bundle exec rails db:schema:load
- run:
name: Run RSpec tests
command: bundle exec rspec
- store_artifacts:
path: coverage
build-and-push:
executor:
name: docker/docker
parameters:
tag:
type: string
default: "rc"
steps:
- checkout
- docker/login:
docker-username: "$DOCKERHUB_USERNAME"
docker-password: "$DOCKERHUB_TOKEN"
- docker/build-publish:
image: "freikin/dawarich:<< parameters.tag >>"
dockerfile: ./docker/Dockerfile.dev
build-args: ""
extra-build-args: "--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6"
registry: "docker.io"
push: true
workflows:
version: 2
build-and-test:
jobs:
- test
- build-and-push:
requires:
- test
filters:
branches:
ignore: /.*/ # Run only on tag builds
tags:
only: /.*/ # Run for any tag
tag: "<< pipeline.parameters.tag >>"