-
Notifications
You must be signed in to change notification settings - Fork 42
77 lines (73 loc) · 2.5 KB
/
build_application_docker.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
on:
workflow_dispatch:
workflow_run:
workflows:
- 'Publish Platform'
- 'Publish Platform Hotfix'
types:
- completed
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
name: Build Application Docker
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
name: datalens-ui
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == '' || github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
packages: write
steps:
- name: Download Artifacts
uses: dawidd6/action-download-artifact@v6
if: ${{ github.event.workflow_run.id != '' }}
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
run_id: ${{ github.event.workflow_run.id }}
- name: Extract commit ref from workflow
run: |
echo "COMMIT_REF=$(cat workflow_ref/ref || echo '${{ github.ref }}')" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
with:
ref: ${{ env.COMMIT_REF || github.ref }}
- uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'
- uses: docker/setup-buildx-action@v3
- name: 'Get release build version'
run: |
BUILD_VERSION=$(jq -r '.version' package.json)
COMMIT_NAME=$(git log -n 1 --pretty=format:%s)
echo "Release build version: ${BUILD_VERSION}"
echo "BUILD_VERSION=$BUILD_VERSION" >> "$GITHUB_ENV"
echo "COMMIT_NAME=$COMMIT_NAME" >> "$GITHUB_ENV"
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tags for Docker
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ env.BUILD_VERSION }}
${{ contains(env.COMMIT_NAME, '[release]') && 'type=raw,value=latest' || '' }}
- name: Build and push Docker image
uses: docker/[email protected]
with:
build-args: |
app_version=${{ env.BUILD_VERSION }}
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max