This commit is contained in:
parent
74e3264562
commit
4bbbfcc577
1 changed files with 36 additions and 51 deletions
|
|
@ -1,70 +1,55 @@
|
||||||
# This workflow will build and test the Rails application
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
name: Build and Test Rails Application
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
env:
|
||||||
|
DOCKER_TLS_CERTDIR: /certs
|
||||||
|
RAILS_ENV: production
|
||||||
|
# GitHub/Forgejo equivalent of CI_REGISTRY_IMAGE + commit refs
|
||||||
|
CONTAINER_IMAGE: ghcr.io/${{ github.repository }}:${{ github.ref_name }}-${{ github.sha }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
|
||||||
services:
|
services:
|
||||||
postgres:
|
docker:
|
||||||
image: postgres:latest
|
image: docker:20.10.16-dind
|
||||||
env:
|
options: --privileged
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
POSTGRES_DB: debshots_test
|
|
||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 2375:2375
|
||||||
options: >-
|
env:
|
||||||
--health-cmd pg_isready
|
DOCKER_TLS_CERTDIR: /certs
|
||||||
--health-interval 10s
|
|
||||||
--health-timeout 5s
|
|
||||||
--health-retries 5
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Ruby
|
- name: Set up Docker CLI
|
||||||
uses: ruby/setup-ruby@v1
|
uses: docker/setup-buildx-action@v3
|
||||||
with:
|
|
||||||
ruby-version: 3.2.4
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Docker info
|
||||||
|
run: docker info
|
||||||
|
|
||||||
|
- name: Log in to container registry
|
||||||
run: |
|
run: |
|
||||||
gem install bundler
|
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login \
|
||||||
bundle install
|
-u "${{ secrets.REGISTRY_USER }}" \
|
||||||
|
--password-stdin \
|
||||||
|
${{ secrets.REGISTRY_URL }}
|
||||||
|
|
||||||
- name: Set up Node.js
|
- name: Build Docker image
|
||||||
uses: actions/setup-node@v2
|
|
||||||
with:
|
|
||||||
node-version: '14'
|
|
||||||
|
|
||||||
- name: Install Yarn
|
|
||||||
run: npm install -g yarn
|
|
||||||
|
|
||||||
- name: Install Node.js dependencies
|
|
||||||
run: yarn install
|
|
||||||
|
|
||||||
- name: Set up database
|
|
||||||
run: |
|
run: |
|
||||||
bundle exec rails db:create db:migrate
|
docker build -t "$CONTAINER_IMAGE" .
|
||||||
env:
|
docker tag "$CONTAINER_IMAGE" "${{ secrets.REGISTRY_IMAGE }}:latest"
|
||||||
RAILS_ENV: test
|
|
||||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/debshots_test
|
|
||||||
|
|
||||||
- name: Run tests
|
- name: Push Docker images
|
||||||
run: bundle exec rails test
|
run: |
|
||||||
env:
|
docker push "$CONTAINER_IMAGE"
|
||||||
RAILS_ENV: test
|
docker push "${{ secrets.REGISTRY_IMAGE }}:latest"
|
||||||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/debshots_test
|
|
||||||
|
|
||||||
- name: Build assets
|
|
||||||
run: bundle exec rails assets:precompile
|
|
||||||
env:
|
|
||||||
RAILS_ENV: production
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue