-
-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (77 loc) · 2.5 KB
/
docker.yml
File metadata and controls
90 lines (77 loc) · 2.5 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
name: Docker Build
on:
workflow_dispatch:
schedule:
# Run every day at midnight
- cron: '0 0 * * *'
push:
paths:
- docker/**/*
- .github/workflows/docker.yml
env:
REGISTRY: ghcr.io
jobs:
build:
name: Build
# We need to make sure both the Dockerfile and the branch is main
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
packages: write
strategy:
matrix:
include:
- name: build
file: docker/build.dockerfile
- name: cockroach
file: docker/cockroach.dockerfile
- name: minio
file: docker/minio.dockerfile
- name: nats
file: docker/nats.dockerfile
- name: redis
file: docker/redis.dockerfile
steps:
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >>${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: Checkout
uses: actions/checkout@v4.1.7
with:
fetch-depth: 0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ matrix.name }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3.6.1
- name: Build Image
id: docker_build
uses: docker/build-push-action@v6.7.0
with:
context: .
file: ./${{ matrix.file }}
push: true
tags: |
${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ matrix.name }}:${{ github.sha }}
${{ env.REGISTRY }}/${{ env.OWNER_LC }}/${{ matrix.name }}:latest
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}