Skip to content

Commit 12365b1

Browse files
committed
CI: Build and publish a docker image
1 parent cdf211c commit 12365b1

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/docker.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-FileCopyrightText: 2021-2024 Robin Vobruba <[email protected]>
2+
#
3+
# SPDX-License-Identifier: Unlicense
4+
5+
name: Publish Docker image
6+
7+
on:
8+
push:
9+
branches: [ master ]
10+
release:
11+
types: [ published ]
12+
13+
env:
14+
IMAGE_NAME: hoijui/okh-db
15+
16+
jobs:
17+
push_to_registry:
18+
name: Push Docker image to Docker Hub
19+
runs-on: ubuntu-latest
20+
steps:
21+
-
22+
name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
fetch-tags: true
27+
submodules: true
28+
-
29+
name: Login to DockerHub
30+
if: github.event_name != 'pull_request'
31+
uses: docker/login-action@v3
32+
with:
33+
username: ${{ vars.DOCKER_USERNAME }}
34+
password: ${{ secrets.DOCKER_PASSWORD }}
35+
-
36+
name: Prepare build meta-data
37+
run: |
38+
# This allows reproducible docker builds
39+
echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
40+
echo "GIT_VERSION=$(git describe --broken --always --tags --dirty)" >> $GITHUB_ENV
41+
-
42+
name: Docker meta
43+
id: meta
44+
uses: docker/metadata-action@v5
45+
with:
46+
images: ${{ env.IMAGE_NAME }}
47+
tags: |
48+
type=schedule
49+
type=ref,event=branch
50+
type=semver,pattern={{version}}
51+
type=semver,pattern={{major}}.{{minor}}
52+
type=semver,pattern={{major}}
53+
type=sha
54+
labels: |
55+
org.opencontainers.image.version=${{ env.GIT_VERSION }}
56+
org.opencontainers.image.documentation=https://github.com/OSEGermany/OKH-RDF-DB/blob/${{ env.GIT_VERSION }}/README.md
57+
org.opencontainers.image.vendor=Open Source Ecology Germany e.V.
58+
-
59+
name: Push to Docker Hub
60+
uses: docker/build-push-action@v6
61+
env:
62+
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
63+
with:
64+
push: ${{ github.event_name != 'pull_request' }}
65+
tags: ${{ steps.meta.outputs.tags }}
66+
labels: ${{ steps.meta.outputs.labels }}
67+
annotations: ${{ steps.meta.outputs.annotations }}
68+
build-args: |
69+
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true

0 commit comments

Comments
 (0)