-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (77 loc) · 2.74 KB
/
backend-build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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"