-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (88 loc) · 3.02 KB
/
Copy pathbuild-postgres.yaml
File metadata and controls
99 lines (88 loc) · 3.02 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
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/postgres
POSTGRES_MAJOR: 17
POSTGRES_MINOR: 5
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- runner: ubuntu-24.04
platform: linux/amd64
arch: amd64
- runner: ubuntu-24.04-arm
platform: linux/arm64
arch: arm64
runs-on: ${{ matrix.os.runner }}
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=${{ env.POSTGRES_MAJOR }}.${{ env.POSTGRES_MINOR }}-{{commit_date 'YYYYMMDD'}}-{{sha}}-${{ matrix.os.arch }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/postgres/Dockerfile
build-args: |
postgresql_major=${{ env.POSTGRES_MAJOR }}
postgresql_minor=${{ env.POSTGRES_MINOR }}
push: true
platforms: ${{ matrix.os.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.os.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.os.platform }}
provenance: false
sbom: false
merge-manifests:
runs-on: ubuntu-24.04
needs: build
permissions:
packages: write
contents: read # Needed to get repository owner and name
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=raw,value=${{ env.POSTGRES_MAJOR }}.${{ env.POSTGRES_MINOR }}-{{commit_date 'YYYYMMDD'}}-{{sha}}
- name: Create and push manifest
run: |
docker manifest create $DOCKER_METADATA_OUTPUT_TAGS \
--amend $DOCKER_METADATA_OUTPUT_TAGS-amd64 \
--amend $DOCKER_METADATA_OUTPUT_TAGS-arm64
docker manifest push $DOCKER_METADATA_OUTPUT_TAGS