Skip to content

Commit ea4b743

Browse files
authored
Update publish-ghcr.yml
1 parent a18d1cb commit ea4b743

File tree

1 file changed

+28
-39
lines changed

1 file changed

+28
-39
lines changed

.github/workflows/publish-ghcr.yml

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,60 @@
11
name: Build and Push Docker Image
2+
23
on:
34
push:
45
branches:
56
- add-actions
7+
- main
8+
69
env:
710
REGISTRY: ghcr.io
811
IMAGE_NAME: ${{ github.repository }}
912

10-
1113
concurrency:
1214
group: push-to-registry-${{ github.head_ref || github.run_id }}
1315
cancel-in-progress: true
1416

1517
jobs:
1618
push_to_registry:
17-
name: Build image
19+
name: Build and Push Docker Image
1820
runs-on: ubuntu-latest
19-
strategy:
20-
fail-fast: false
21-
21+
2222
permissions:
23-
packages: write
2423
contents: read
24+
packages: write
25+
2526
steps:
26-
- name: Check out the repo
27+
- name: Checkout repository
2728
uses: actions/checkout@v4
28-
- name: Docker meta
29-
uses: docker/metadata-action@v5
30-
id: meta
31-
32-
- name: Set up QEMU
33-
uses: docker/setup-qemu-action@v3
29+
3430
- name: Set up Docker Buildx
3531
uses: docker/setup-buildx-action@v3
36-
- name: Cache Docker layers
37-
uses: actions/cache@v4
38-
with:
39-
path: /tmp/.buildx-cache
40-
key: ${{ matrix.container }}-buildx-${{ github.sha }}
41-
restore-keys: |
42-
${{ matrix.container }}-buildx-
43-
- name: Log in to GitHub Container Registry
32+
33+
- name: Log in to Container Registry
4434
uses: docker/login-action@v3
4535
with:
46-
registry: ghcr.io
36+
registry: ${{ env.REGISTRY }}
4737
username: ${{ github.actor }}
4838
password: ${{ secrets.GITHUB_TOKEN }}
49-
- name: Build container image
50-
uses: docker/build-push-action@v6
39+
40+
- name: Extract metadata
41+
id: meta
42+
uses: docker/metadata-action@v5
5143
with:
52-
push: false
53-
context: .docker
54-
platforms: linux/amd64,linux/arm64
55-
file: .docker/app/Dockerfile
56-
tags: ${{ steps.meta.outputs.tags }}
57-
58-
- name: Push container image
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
tags: |
46+
type=ref,event=branch
47+
type=sha,prefix=sha-
48+
type=raw,value=latest,enable={{is_default_branch}}
49+
50+
- name: Build and push Docker image
5951
uses: docker/build-push-action@v6
6052
with:
61-
push: true
6253
context: .docker
63-
platforms: linux/amd64,linux/arm64
6454
file: .docker/app/Dockerfile
55+
platforms: linux/amd64,linux/arm64
56+
push: true
6557
tags: ${{ steps.meta.outputs.tags }}
66-
cache-from: type=local,src=/tmp/.buildx-cache
67-
cache-to: type=local,dest=/tmp/.buildx-cache-new
68-
- name: Move cache
69-
run: |
70-
rm -rf /tmp/.buildx-cache
71-
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)