-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (92 loc) · 3.24 KB
/
docker-image.yml
File metadata and controls
107 lines (92 loc) · 3.24 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Docker image
on:
push:
branches:
- develop
tags:
- '[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
env:
DEFAULT_PYTHON: '3.14'
jobs:
release:
name: Build & push image to Dockerhub
runs-on: ubuntu-latest
if: github.repository == 'MTSWebServices/horizon' # prevent running on forks
permissions:
contents: read
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Get version
id: get_version
run: |
echo "VERSION=$(cat horizon/VERSION)" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: mtsrus/horizon-backend
labels: |
org.opencontainers.image.title=Horizon
org.opencontainers.image.vendor=MTS PJSC
org.opencontainers.image.documentation=https://data-horizon.readthedocs.io
org.opencontainers.image.url=https://hub.docker.com/r/mtsrus/horizon-backend
org.opencontainers.image.authors=MWS Data Bridge <onetools@mts.ru>
org.opencontainers.image.version=${{ env.VERSION }}
- name: Set platforms
id: set_platforms
run: |
# Building krb5 on ARM is time consuming, do this only at release
if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "develop" ]]; then
echo "PLATFORMS=linux/amd64" >> $GITHUB_ENV
elif [[ "${{ github.ref_type }}" == "tag" ]]; then
echo "PLATFORMS=linux/amd64,linux/arm64/v8" >> $GITHUB_ENV
fi
- name: Build Backend image
uses: docker/build-push-action@v7
with:
context: .
target: prod
file: docker/Dockerfile.backend
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
pull: true
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: ${{ env.PLATFORMS }}
provenance: mode=max
sbom: true
- name: Convert README to Markdown
uses: docker://pandoc/core:2.9
with:
args: >-
--output=README.md
--from=rst
--to=gfm
--wrap=none
README.rst
- name: Update DockerHub Description
uses: peter-evans/dockerhub-description@v5
if: github.ref_type == 'tag'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
# this requires token with read+write+delete permissions. read+write is not enough!
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: mtsrus/horizon-backend
short-description: ${{ github.event.repository.description }}
enable-url-completion: true