Skip to content

Merge pull request #156 from effectivemade/backend #4

Merge pull request #156 from effectivemade/backend

Merge pull request #156 from effectivemade/backend #4

name: Build and push backend
on:
push:
branches:
- develop
- backend
paths:
- "effectiveOfficeBackend/**"
workflow_dispatch:
inputs:
hash:
description: "Commit sha256sum"
required: false
type: string
env:
BACKEND_ROOT: effectiveOfficeBackend
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.hash || env.GITHUB_REF }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# More info on https://cloud.yandex.ru/docs/container-registry/operations/authentication#sa-json
- name: Login to Yandex Container Registry
uses: docker/login-action@v2
with:
registry: cr.yandex
username: json_key
password: ${{ secrets.YACLOUD_JSON_KEY }}
# FIXME: deprecated set-output
- name: Extract current commit properties
id: commit_properties
run: |
echo "::set-output name=branch::$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=short_hash::$(git rev-parse --short HEAD)"
echo "::set-output name=full_hash::$(git rev-parse HEAD)"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build and push the Docker image
uses: docker/build-push-action@v4
with:
provenance: false
cache-from: type=registry,ref=${{ vars.DOCKERHUB_BACKEND_IMAGE }}
cache-to: type=registry,ref=${{ vars.DOCKERHUB_BACKEND_IMAGE }}
context: ${{ env.BACKEND_ROOT }}
push: true
tags: |
${{ vars.DOCKERHUB_BACKEND_IMAGE }}:${{ steps.commit_properties.outputs.branch }}
${{ vars.DOCKERHUB_BACKEND_IMAGE }}:${{ steps.commit_properties.outputs.short_hash }}
${{ vars.DOCKERHUB_BACKEND_IMAGE }}:${{ steps.commit_properties.outputs.full_hash }}
${{ vars.YACLOUD_BACKEND_IMAGE }}:${{ steps.commit_properties.outputs.branch }}
migrations:
name: Run migrations
runs-on: ubuntu-22.04
needs: build
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.hash || env.GITHUB_REF }}
- name: Run migrations against current master changelog
uses: liquibase-github-actions/[email protected]
with:
changelogFile: changelog/changelog-master.yaml
searchPath: ${{ env.BACKEND_ROOT }}/src/main/resources/
# The JDBC database connection URL
url: ${{ vars.DATABASE_URL }}
username: ${{ vars.DATABASE_USERNAME }}
password: ${{ secrets.DATABASE_PASSWORD }}
rollbackOnError: true
showSummary: "summary"