Skip to content

Commit fae907a

Browse files
committed
Update ci
1 parent a580130 commit fae907a

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

.github/workflows/build-and-push-images.yml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,56 @@ on:
44
push:
55
branches: ['master']
66

7+
permissions:
8+
packages: write
9+
contents: read
10+
11+
712
jobs:
813
build-and-push-image:
914
runs-on: ubuntu-latest
1015

16+
env:
17+
GIT_LFS_SKIP_SMUDGE: 1
18+
REGISTRY_URL: ghcr.io
19+
REPOSITORY: ${{ github.repository }}
20+
1121
strategy:
1222
matrix:
1323
include:
14-
- { postgres: 12, alpine: '3.12' }
15-
- { postgres: 13, alpine: '3.14' }
16-
- { postgres: 14, alpine: '3.16' }
17-
- { postgres: 15, alpine: '3.17' }
1824
- { postgres: 16, alpine: '3.19' }
1925

2026
steps:
2127
- name: Checkout repository
22-
uses: actions/checkout@v2
23-
24-
- name: Set up QEMU
25-
uses: docker/setup-qemu-action@v1
26-
28+
uses: actions/checkout@v5
2729
- name: Set up Docker Buildx
28-
uses: docker/setup-buildx-action@v1
29-
30-
- name: Log in to DockerHub
31-
uses: docker/login-action@v1
30+
uses: docker/setup-buildx-action@v3
31+
- name: Docker meta
32+
id: meta
33+
uses: docker/metadata-action@v5
3234
with:
33-
username: ${{ secrets.DOCKERHUB_USERNAME }}
34-
password: ${{ secrets.DOCKERHUB_TOKEN }}
35-
35+
images: ${{ env.REGISTRY_URL }}/${{ env.REPOSITORY }}
36+
flavor: |
37+
latest=auto
38+
prefix=${{ matrix.postgres }}
39+
suffix=
40+
tags: |
41+
type=ref,event=branch,prefix=${{ matrix.postgres }}-branch-
42+
type=ref,event=pr,prefix=${{ matrix.postgres }}-pr-
43+
- name: Login to GHCR
44+
uses: docker/login-action@v3
45+
with:
46+
registry: ghcr.io
47+
username: ${{ github.repository_owner }}
48+
password: ${{ secrets.GITHUB_TOKEN }}
3649
- name: Build and push Docker image
37-
uses: docker/build-push-action@v2
50+
uses: docker/build-push-action@v6
3851
with:
3952
context: .
4053
push: true
41-
tags: ${{ github.repository }}:${{ matrix.postgres }}
4254
build-args: |
4355
ALPINE_VERSION=${{ matrix.alpine }}
44-
platforms: |
45-
linux/amd64
46-
linux/arm64
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha, scope=${{ matrix.docker.image }}, mode=max
59+
cache-to: type=gha, scope=${{ matrix.docker.image }}, mode=max

0 commit comments

Comments
 (0)