Skip to content

Merge pull request #453 from UffizziCloud/feature/1119_uffizzi_platfo… #1544

Merge pull request #453 from UffizziCloud/feature/1119_uffizzi_platfo…

Merge pull request #453 from UffizziCloud/feature/1119_uffizzi_platfo… #1544

Workflow file for this run

name: Test, Lint, Build, and Publish Image
on:
push:
branches:
- qa
- develop
- main
pull_request:
types: [opened,synchronize,reopened]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.5
bundler-cache: true
- name: Run rubocop
run: bundle exec rubocop
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create env file
uses: SpicyPizza/[email protected]
- name: Run tests
run: docker-compose run --rm core bash -c "bundle install && bundle exec rails db:create && bundle exec rails test"
build-and-push-some-branches:
runs-on: ubuntu-latest
needs:
- lint
- test
if: ${{ github.ref_name == 'main' || github.ref_name == 'qa' || github.ref_name == 'develop' || github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: uffizzi/app
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=branch,enable=${{ github.ref_name == 'qa' || github.ref_name == 'develop' }}
type=ref,event=pr
- name: Build and Push Image to Docker Hub
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Update Docker Hub Description for Default Branch
uses: peter-evans/[email protected]
if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
repository: uffizzi/app
notify:
needs:
- lint
- test
- build-and-push-some-branches
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- uses: technote-space/workflow-conclusion-action@v2
- uses: 8398a7/action-slack@v3
with:
status: ${{ env.WORKFLOW_CONCLUSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: ${{ (github.ref_name == 'main' && env.WORKFLOW_CONCLUSION == 'success') || ((github.ref_name == 'main' || github.ref_name == 'qa' || github.ref_name == 'develop') && env.WORKFLOW_CONCLUSION == 'failure') }}