|
4 | 4 | push: |
5 | 5 | branches: ['master'] |
6 | 6 |
|
| 7 | +permissions: |
| 8 | + packages: write |
| 9 | + contents: read |
| 10 | + |
| 11 | + |
7 | 12 | jobs: |
8 | 13 | build-and-push-image: |
9 | 14 | runs-on: ubuntu-latest |
10 | 15 |
|
| 16 | + env: |
| 17 | + GIT_LFS_SKIP_SMUDGE: 1 |
| 18 | + REGISTRY_URL: ghcr.io |
| 19 | + REPOSITORY: ${{ github.repository }} |
| 20 | + |
11 | 21 | strategy: |
12 | 22 | matrix: |
13 | 23 | 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' } |
18 | 24 | - { postgres: 16, alpine: '3.19' } |
19 | 25 |
|
20 | 26 | steps: |
21 | 27 | - 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 |
27 | 29 | - 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 |
32 | 34 | 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 }} |
36 | 49 | - name: Build and push Docker image |
37 | | - uses: docker/build-push-action@v2 |
| 50 | + uses: docker/build-push-action@v6 |
38 | 51 | with: |
39 | 52 | context: . |
40 | 53 | push: true |
41 | | - tags: ${{ github.repository }}:${{ matrix.postgres }} |
42 | 54 | build-args: | |
43 | 55 | 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