-
Notifications
You must be signed in to change notification settings - Fork 4
106 lines (95 loc) · 3.2 KB
/
builds.yaml
File metadata and controls
106 lines (95 loc) · 3.2 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
name: Docker Builds
on:
push:
branches:
- main
pull_request:
branches:
- main
paths:
- '.github/workflows/builds.yaml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
BASE_NAME: graphops/docker-builds
DOCKER_BUILDKIT: 1
BUILDX_NO_DEFAULT_LOAD: 1
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
context:
- init-toolbox
- graph-toolbox
- temporalite
- init-stream-download
- netbox
- altair
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract versions from Dockerfile
id: versions
run: |
set -exo pipefail;
# Extract versions and store as JSON
versions=$(./scripts/extract-versions.sh "./dockerfiles/${{ matrix.context }}/Dockerfile")
# Validate JSON and store
echo "$versions" | jq '.' > /dev/null # Validate JSON
echo "versions=$versions" >> $GITHUB_OUTPUT
# Create hyphen-separated version string
version_string=$(echo "$versions" | jq -r 'map(.value) | join("-")')
echo "version_string=$version_string" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.BASE_NAME }}/${{ matrix.context }}
tags: |
# Version-based tag from concatenated versions
type=sha
type=raw,value=${{ steps.versions.outputs.version_string }}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=branch
labels: |
org.opencontainers.image.title=${{ matrix.context }}
org.opencontainers.image.description=Docker image for ${{ matrix.context }}
org.opencontainers.image.vendor=GraphOps
org.opencontainers.image.versions=${{ steps.versions.outputs.versions }}
- name: Check if context changed
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'dockerfiles/${{ matrix.context }}/**'
- '.github/workflows/builds.yaml'
- 'scripts/extract-versions.sh'
- name: Login to GitHub Container Registry
if: steps.changes.outputs.src == 'true' && github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: steps.changes.outputs.src == 'true'
uses: docker/build-push-action@v5
with:
context: ./dockerfiles/${{ matrix.context }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false