Merge pull request #534 from sanger/depfu/update/guard-2.19.0 #134
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker CI | |
on: | |
push: | |
branches: | |
- develop | |
- master | |
paths-ignore: | |
- "README.md" | |
tags: | |
- uat-* | |
- release-* | |
- v* | |
env: | |
IMAGE_NAME: ${{ github.repository }}/${{ github.event.repository.name }} | |
jobs: | |
build_and_test_job: | |
runs-on: ubuntu-latest | |
env: | |
LOCALHOST: 127.0.0.1 # If we use 'localhost', rails tries to use a socket | |
services: | |
mysql: | |
image: mysql:8.0 | |
ports: | |
- 3306:3306 | |
env: | |
MYSQL_ALLOW_EMPTY_PASSWORD: yes | |
MYSQL_ROOT_PASSWORD: null | |
MYSQL_DATABASE: event_warehouse_test | |
rmq: | |
image: rabbitmq:3 | |
ports: | |
- 5672:5672 | |
env: | |
RABBITMQ_DEFAULT_USER: guest | |
RABBITMQ_DEFAULT_PASS: guest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: nelonoel/[email protected] | |
- name: Build the Docker image | |
run: >- | |
docker build . | |
--file Dockerfile | |
--tag docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} | |
- name: Run Rubocop against the image | |
run: >- | |
docker run --network host --env DBHOST=$LOCALHOST | |
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} | |
bundle exec rubocop | |
- name: Initialize testing database | |
run: >- | |
docker run --network host --env DBHOST=$LOCALHOST | |
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} | |
bundle exec rake db:create db:schema:load db:seed | |
- name: Run tests against the image | |
run: >- | |
docker run --network host --env DBHOST=$LOCALHOST | |
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} | |
bundle exec rspec | |
- name: Login to registry | |
run: >- | |
docker login | |
-u ${{ github.actor }} | |
-p ${{ secrets.GITHUB_TOKEN }} | |
docker.pkg.github.com | |
- name: Publish image with image tag being either develop/master/<tag_name> | |
run: >- | |
docker push | |
docker.pkg.github.com/${IMAGE_NAME}:${BRANCH_NAME} |