Merge pull request #283 from effectivemade/backendApp/hotfix/null-eve… #49
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: 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/update@v4.23.0 | |
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" |